1
0
Fork 0
forked from 0x2620/oxjs

workaround for select values not getting updated correctly when updating form values

This commit is contained in:
rlx 2011-10-11 11:22:16 +00:00
commit f43122f795
4 changed files with 39 additions and 24 deletions

View file

@ -484,7 +484,7 @@ Ox.ListCalendar = function(options, self) {
selectEvent(event);
self.$nameInput.focusInput();
} else {
alert(result.status.code)
alert(result.status.text);
}
});
}
@ -495,22 +495,26 @@ Ox.ListCalendar = function(options, self) {
data = {id: id};
data[key] = value;
self.options.editEvent(data, function(result) {
self.options.events[index][key] = value;
self.$list.value(id, key, value);
if (['name', 'type', 'start', 'end'].indexOf(key) > -1) {
self.$calendar.editEvent(id, key, value);
}
if (key == 'name') {
self.$eventName.options({title: value});
} else if (['start', 'end'].indexOf(key) > -1) {
self.$durationInput.options({
value: Ox.formatDateRangeDuration(
self.$startInput.options('value'),
self.$endInput.options('value')
|| Ox.formatDate(new Date(), '%Y-%m-%d %H%:%M:%S'),
true
)
});
if (result.status.code == 200) {
self.options.events[index][key] = value;
self.$list.value(id, key, value);
if (['name', 'type', 'start', 'end'].indexOf(key) > -1) {
self.$calendar.editEvent(id, key, value);
}
if (key == 'name') {
self.$eventName.options({title: value});
} else if (['start', 'end'].indexOf(key) > -1) {
self.$durationInput.options({
value: Ox.formatDateRangeDuration(
self.$startInput.options('value'),
self.$endInput.options('value')
|| Ox.formatDate(new Date(), '%Y-%m-%d %H%:%M:%S'),
true
)
});
}
} else {
alert(result.status.text);
}
});
}
@ -546,12 +550,16 @@ Ox.ListCalendar = function(options, self) {
var id = self.selectedEvent,
index = Ox.getPositionById(self.options.events, id);
self.options.removeEvent({id: id}, function(result) {
self.options.events.splice(index, 1);
var time0 = +new Date();
self.$list.options({items: Ox.clone(self.options.events, true)});
Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0);
self.$calendar.removeEvent();
selectEvent({});
if (result.status.code == '200') {
self.options.events.splice(index, 1);
var time0 = +new Date();
self.$list.options({items: Ox.clone(self.options.events, true)});
Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0);
self.$calendar.removeEvent();
selectEvent({});
} else {
alert(result.status.text);
}
});
}