Let's say I have a grid and create it using it like so:
$( "#dragIt" ).draggable({ grid: [ 15, 15 ] });
Then, I have a checkbox below the div
. Is there anyway when I toggle the checkbox, that the grid becomes on and off? I can't find in the official jQuery ui website how to turn it off/on.
Try this one: http://jsbin.com/ewamuq/1/edit
$(function () {
$("#draggable4").draggable({
grid: [15, 15]
});
$('input[type="checkbox"]').change(function () {
if ($(':checked').length > 0) {
$("#draggable4").draggable({
grid: false
});
} else {
$("#draggable4").draggable({
grid: [15, 15]
});
}
});
});