javascript - Knockout move observableArray item down -


from this question, know how move item up:

moveup: function(category) {     var = categories.indexof(category);     if (i >= 1) {         var array = categories();         categories.splice(i-1, 2, array[i], array[i-1]);     } } 

what equivalent moving item down?

in solution, delete 2 items, index position, , again insert them (first - next item, , second - moving item):

movedown = function(number) {     var = self.numbers().indexof(number);     if (i < self.numbers().length - 1) {         var rawnumbers = self.numbers();         self.numbers.splice(i, 2, rawnumbers[i + 1], rawnumbers[i]);     } } 

demo


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -