Draggable demo: Implemented cancel option in handle demo.

This commit is contained in:
Scott González 2012-01-28 10:52:27 -05:00
parent f5ceca740f
commit 2eb9b841a3

View File

@ -15,6 +15,19 @@
#draggable p { cursor: move; }
</style>
<script>
$.widget( "ui.draggable", $.ui.draggable, {
options: {
cancel: null
},
_isValidTarget: function( element ) {
var valid = this._super( element );
if ( valid && this.options.cancel ) {
valid = !element.is( this.options.cancel );
}
return valid;
}
});
$(function() {
$( "#draggable" ).draggable({ handle: "p" });
$( "#draggable2" ).draggable({ cancel: "p.ui-widget-header" });
@ -31,11 +44,9 @@
<div id="draggable2" class="ui-widget-content">
<p>You can drag me around&hellip;</p>
<p class="ui-widget-header">&hellip;but you can't drag me by this handle.</p>
<p class="ui-widget-header">&hellip;but you can't drag me by this element.</p>
</div>
<!-- ADD CANCEL DEMO -->
</div><!-- End demo -->