Droppable(options)
With the Draggables plugin, Droppable allows you to create drop zones for draggable elements.
参数
- options (Hash): A hash of options
Hash 选项
- accept (String): The class name for draggables to get accepted by the droppable (mandatory)
- activeclass (String): When an acceptable draggable is moved, the droppable gets this class
- hoverclass (String): When an acceptable draggable is inside the droppable, the droppable gets this class
- tolerance (String): Choose from 'pointer', 'intersect', or 'fit'. The pointer options means that the pointer must be inside the droppable in order for the draggable to be dropped. The intersect option means that the draggable must intersect the droppable. The fit option means that the entire draggable must be inside the droppable.
- onDrop (Function): When an acceptable draggable is dropped on a droppable, this callback is called. It passes the draggable DOMElement as a parameter.
- onHover (Function): When an acceptable draggable is hovered over a droppable, this callback is called. It passes the draggable DOMElement as a parameter.
- onOut (Function): When an acceptable draggable leaves a droppable, this callback is called. It passes the draggable DOMElement as a parameter.
示例
jQuery 代码:
$('#dropzone1').Droppable( { accept : 'dropaccept', activeclass: 'dropzoneactive', hoverclass: 'dropzonehover', ondrop: function (drag) { alert(this); //the droppable alert(drag); //the draggable }, fit: true } )
|