Search code examples
c#javascriptjqueryasp.netblockui

Enabling Sortable in jquery


I want to disable jquery sortable on page load but not sure, someone direct me in right direction please,

In jquery I can do it like this $(".myList").sortable('disable');

Scenario

I have a checkbox based on which I am enabling and disabling jquery sortable for a list, now I can use $(document).ready(function() { and $(checkbox).change(function() { to disable and enable dragging but I can't check it on page load in code behind as checkbox is getting its value from database on pageload.


Solution

  • $(document).ready(function() { 
            if ($('#chcekbox).is(':checked')) {
            $(".myList").sortable('enable');
        } else {
            $(".myList").sortable('disable');
        }  
    });