jquery - Sortable using 2 parameters javascript -
i using sortable sorting entries. works fine simple position numbers , when drag , drop entry can update position number , display accordingly. problem when user drags entry want update parameter time.
i have created jsfiddle demo here can have more idea of problem.
initially looks fine
but when drag entries updates position number , not time. want time updated well.
as suggested alex, should call calculatetime again. change rather grabbing data input again, can store input in variable , grab data variable.
//here set stored variable var stored_starttime, stored_minuteperround; $(document).ready(function() { $("#timing").click( function() { //here set value of stored variable stored_starttime = document.getelementbyid("stime").value; stored_minuteperround = document.getelementbyid("rounds").value; calculatetime(stored_starttime, stored_minuteperround); } ); }); $("#sortable_nav").sortable({ placeholder: "ui-state-highlight", helper: 'clone', sort: function(e, ui) { $(ui.placeholder).html(number($("#sortable_nav > li:visible").index(ui.placeholder)) + 1); }, update: function(event, ui) { var $lis = $(this).children('li'); $lis.each(function() { var $li = $(this); var newval = $(this).index() + 1; $(this).children('.sortable-number').html(newval); //here check if stored variables defined if (stored_starttime !== undefined && stored_minuteperround !== undefined){ calculatetime(stored_starttime, stored_minuteperround); } }); } }); $("#sortable_nav").disableselection(); here jsfiddle http://jsfiddle.net/zjhez393/5/


Comments
Post a Comment