jqueryjquery-uijquery-ui-draggablesnap-to-grid

How to disable "snap to grid" from jQuery UI draggable?


Anyone know how we can disable "Snap to Grid" from jQuery UI Draggable base on checkbox.

I m using below code to enable snap to grid dynamically.

$(".WidgetCl").draggable({containment: '#editorWindow',scroll: true, snap: ".gridCol", snapMode: "both", stop :function() {$(this).trigger("stopdrag");}})
            $(".WidgetCl").draggable("option", "grid", [ gridSize, gridSize ]);

Thanks, Sonal


Solution

  • You have to set the grid option to false to disable snap-to-grid:

    $(".WidgetCl").draggable("option", "grid", false);