droppable

How do I trigger the Drop event with jQuery UI Droppable without actually dragging and dropping?

依然范特西╮ 提交于 2019-11-28 09:53:01
I have a droppable with a drop event handler: $(this).droppable({ drop:function(){ console.log('OMG You Dropped It!'); } }); I have a draggable : $(this).draggable(); What I want to do is trigger the drop event handler on the droppable without actually dragging and dropping the draggable . I want to simulate the actual behavior without physically performing the behavior. I thought something like this would do: $(droppable).trigger('drop', [draggable]); Unfortunately, it's not quite that simple. Does anyone know how I can accomplish this? You should move the code in your drop handler to a

JQuery-UI draggable reset to original position

最后都变了- 提交于 2019-11-28 03:07:46
问题 This is probably very easy to do, but I always think too complicated. I've just set up a simple test with #draggable / #droppable with a fixed width/height + float:left. I then want a reset button to be able to reset the #draggable to it's original state after it's been snapped to a #droppable. (bottom line) $(document).ready(function() { $("#draggable").draggable ({ revert: 'invalid', snap: '#droppable', snapMode: 'corner', snapTolerance: '22' }); }); $("#droppable").droppable ({ accept: '

Programmatically drag and drop element onto another element

旧城冷巷雨未停 提交于 2019-11-27 16:13:22
With jQuery UI, is it possible to execute a drag & drop operation using javascript? Example . When the link is clicked, drag the #pony and drop it into the #box . I've tried triggering the drag event but that doesn't seem work :) $('#pony').trigger('drag', [$('#box')]); This is how the jQuery UI team programmatically trigger drop event. droppable_events.js : draggable = $( "#draggable1" ).draggable(), droppable1 = $( "#droppable1" ).droppable( config ), droppable2 = $( "#droppable2" ).droppable( config ), droppableOffset = droppable1.offset(), draggableOffset = draggable.offset(), dx =

jquery droppable accept

我的梦境 提交于 2019-11-27 10:53:24
问题 Can anyone tell me how I can write a function in accept condition and then how does it finds out that what to accept and what not to accept. For example, I want to accept div a and div b in accept condition. How can I write I through a function? 回答1: If you want the droppable to accept a selection of elements you can do something like this: $(".droppable").droppable({ accept: function(d) { if(d.hasClass("foo")||(d.attr("id")=="bar")){ return true; } } }); This droppable will accept elements

jQuery draggable + droppable: how to snap dropped element to dropped-on element

情到浓时终转凉″ 提交于 2019-11-27 06:14:33
I have my screen divided into two DIV s. In the left DIV I have a few 50x50 pixel DIV s, in the right DIV I have an empty grid made of 80x80 LI s. The DIV s on the left are draggable, and once dropped on a LI , they should snap to center of that LI . Sounds simple, right? I just don't know how to get this done. I tried by manipulating the dropped DIV 's top and left CSS properties to match those of the LI they're dropped into, but the left and top properties are relative to the left DIV . How can I best have the dropped element snap to the center of the element it's dropped into? That's gotta

How do I trigger the Drop event with jQuery UI Droppable without actually dragging and dropping?

拈花ヽ惹草 提交于 2019-11-27 03:15:58
问题 I have a droppable with a drop event handler: $(this).droppable({ drop:function(){ console.log('OMG You Dropped It!'); } }); I have a draggable : $(this).draggable(); What I want to do is trigger the drop event handler on the droppable without actually dragging and dropping the draggable . I want to simulate the actual behavior without physically performing the behavior. I thought something like this would do: $(droppable).trigger('drop', [draggable]); Unfortunately, it's not quite that

Drag-Drop elements between parent frame and child iframe

久未见 提交于 2019-11-26 23:04:20
问题 I am trying to drag-drop elements between parent frame and iframe using jQuery. I have a panel in parent frame which contains some draggable items which can be dropped on the child frame. I tried to search a lot but couldn't find much... I tried to work around it by appending the element inside the child frame and then trying to trigger draggable on the newly inserted element programmatically, but I got stuck there as well. Couldn't find the proper way to trigger the drag function. (The

Programmatically drag and drop element onto another element

只谈情不闲聊 提交于 2019-11-26 17:25:18
问题 With jQuery UI, is it possible to execute a drag & drop operation using javascript? Example. When the link is clicked, drag the #pony and drop it into the #box . I've tried triggering the drag event but that doesn't seem work :) $('#pony').trigger('drag', [$('#box')]); 回答1: This is how the jQuery UI team programmatically trigger drop event. droppable_events.js: draggable = $( "#draggable1" ).draggable(), droppable1 = $( "#droppable1" ).droppable( config ), droppable2 = $( "#droppable2" )