html5 - Button is not showing up when jquery sortable list is changed -
i using jquery sortable functionality, , have list sortable, want save sorted order button show if user change sorting order otherwise button should not displayed. have written own function showbutton , calling in update attribute of jquery sortable function not working. below code:
<script> $(function() { $( "#sortable" ).sortable({ placeholder: "ui-state-highlight", cursor: 'crosshair', update: function(event, ui) { var order = $("#sortable").sortable("toarray"); $('#sorted_order').val(order.join(",")); showbutton(); } }); $( "#sortable" ).disableselection(); }); function showbutton() { var field = "#somefield_id";//is field after want button show $node = '<input type="submit" id="savebtn" value="save order">'; $(field).after($node); };
please suggest if there other way to this. in advance
i assume want user able see button when have finished sorting. in case, use 'stop'. e.g.:
$( "#sortable" ).sortable({ placeholder: "ui-state-highlight", cursor: 'crosshair', update: function(event, ui) { var order = $("#sortable").sortable("toarray"); $('#sorted_order').val(order.join(",")); }, stop: function() { showbutton(); } });
read more in api stop.
Comments
Post a Comment