javascript - Vue.js Sortable list - updating model and saving position on change through AJAX -
fiddle:
https://jsfiddle.net/fierflash/0h6ul4ek/2/
objective:
when re-order takes place(through sortable), send ajax request backend save new positions of tasks
whats v-sortable?
http://am2studio.hr/blog/creating-dynamic-table-with-vue-js/
problem
- the markup updated model not updated. in case value of task.position remains same when re-order takes place.
- how should
$watch
this(if needed)? values should put in?
how solve this?
the main problem running approach trying update position using input
type="hidden"
. vue's v-model
not support input type (and unfortunately doesn't emit error message in case either).
since trying update position after drop ends, why not walk array , set afterwards this?
that.value.foreach(function (task, index) { task.position = index + 1; });
working fiddle here: https://jsfiddle.net/zuwg1dh6/1/
Comments
Post a Comment