forked from 0x2620/oxjs
make annotations sortable
This commit is contained in:
parent
11d9b63dba
commit
43d04f242d
2 changed files with 22 additions and 18 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue