javascript - Remove draggable containment -
you can add containment dynamically this:
$(this).draggable( "option", "containment", "parent" );
how remove containment again? like:
$(this).draggable( "option", "containment", "none" );
except doesn't work.. not find methods in api documentation
edit: want able drag item no containment. using checkboxes:
var denne = $(this); if ($('#containment').is(':checked')) { $(this).draggable( "option", "containment", "parent" ); } $("#containment").each(function(){ if ($(this).prop('checked')==false){ denne.draggable( "option", "containment", false ); } });
depending on want do...
you "disable" element no longer draggable.
$(this).draggable( "option", "disabled", true );
or change containment boundaries element can draggable outside of original constraints.
$(this).draggable( "option", "containment", "window" );
or specifying exact boundaries.
$(this).draggable( "option", "containment", [x1, y1, x2, y2] );
or menencia mentioned in comments, try setting containment false
$(this).draggable( "option", "containment", false );