1
0
Fork 0
forked from 0x2620/oxjs

allow for editing of alternative names

This commit is contained in:
rolux 2011-05-30 10:46:12 +02:00
commit c99e7af1bd
4 changed files with 37 additions and 19 deletions

View file

@ -5,7 +5,7 @@ Ox.ArrayInput = function(options, self) {
.defaults({
label: '',
max: 0,
sort: false,
sort: false, // fixme: this should probably be removed
value: [],
width: 256
})
@ -50,6 +50,7 @@ Ox.ArrayInput = function(options, self) {
.bindEvent({
change: function(data) {
self.options.sort && data.value !== '' && sortInputs();
that.triggerEvent('change', {value: that.value()});
}
})
.appendTo(self.$element[i]));
@ -62,7 +63,12 @@ Ox.ArrayInput = function(options, self) {
.css({float: 'left', marginLeft: '8px'})
.bind({
click: function() {
removeInput($(this).parent().data('index'));
var index = $(this).parent().data('index');
if (self.$input[index].value() !== '') {
self.$input[index].options({value: ''});
that.triggerEvent('change', {value: that.value()});
}
removeInput(index);
}
})
.appendTo(self.$element[i]));
@ -132,12 +138,13 @@ Ox.ArrayInput = function(options, self) {
self.setOption = function(key, value) {
if (key == 'value') {
Ox.print('--value--', value, self.$input)
if (self.options.value.length == 0) {
self.options.value = [''];
}
self.$input && self.$input.forEach(function($input, i) {
removeInput(i);
});
while (self.$input.length) {
removeInput(0);
}
self.options.value.forEach(function(value, i) {
addInput(i, value);
});