1
0
Fork 0
forked from 0x2620/oxjs

make annotations sortable

This commit is contained in:
rlx 2012-01-11 16:41:13 +05:30
commit 43d04f242d
2 changed files with 22 additions and 18 deletions

View file

@ -16,6 +16,7 @@ Ox.ArrayEditable = function(options, self) {
items: [],
position: -1,
selected: '',
sort: [],
submitOnBlur: true,
type: 'input',
width: 256
@ -106,7 +107,11 @@ Ox.ArrayEditable = function(options, self) {
function renderItems() {
that.empty();
self.options.items.forEach(function(item, i) {
(
Ox.isEmpty(self.options.sort)
? self.options.items
: Ox.sortBy(self.options.items, self.options.sort)
).forEach(function(item, i) {
i && self.options.type == 'input'
&& $('<span>')
.html(', ')
@ -216,6 +221,8 @@ Ox.ArrayEditable = function(options, self) {
renderItems();
} else if (key == 'selected') {
selectItem(value);
} else if (key == 'sort') {
renderItems();
}
}