Hi,
this is weird- stop should trigger all the time. However, there was a bug
that values changed to snap were simply not reported to the callbacks -
maybe that's what causing you pain. I tested again with the latest version
in SVN, soon to be released as 1.6 final, and it worked fine for me.
Also, if you need finer grained control, you can set snap to:
snap: {
items: ':data(draggable)', //That's the default, the items it should
snap to
snap: function(event, ui) {},
release: function(event, ui) {}
}
This way, you have access to two additional events that inform you about a
snap. You can even see to witch element it snapped, in ui.snapItem.
Hope this helps,
Paul
On Fri, Jan 9, 2009 at 5:57 AM, [email protected] <
[email protected]> wrote:
>
> Hello,
>
> Just had a quick question about the snap abilities of a draggable div.
> I'm using the "stop" param to trigger an ajax call to update the div's
> position for persistence.
>
> The problem is that if a div "snaps" to another div/container, the
> drag:stop param isn't triggered (ie it's not being dragged anymore -
> it snapped automatically).
>
> This is like what I currently have:
>
> $("div#box").draggable({
> grid: [2,2],
> snap: true,
> snapTolerance: 4,
> containment: "div#box_container",
> stop: function() {
> alert(' i was dragged ');
> }
> });
>
> When the div gets within 4 pixels ("snapTolerance: 4") of any parent
> border, it will "pop" into place without triggering "stop" so the
> alert never shows and the position never gets saved even though it
> moved.
>
> When I refresh the page, the boxes are in the position they where
> before they snapped.
>
> In place of the alert is a bunch of code that saves the boxes
> position.
>
> Just wondering how I can trigger an event with the snap param, like:
>
> $("div#box").draggable({
> grid: [2,2],
> snap: true,
> snapTolerance: 4,
> containment: "div#box_container",
> stop: function() {
> alert(' i was dragged ');
> }
>
>
> // LIKE...
>
> snapStop: function() {
> alert(' i was snapped ');
> }
>
> onSnap: function() {
> alert(' i was snapped ');
> }
>
>
> });
>
> But I don't see anything in the documentation relating to this.
>
> Thanks in advance.
>
> >
>
--
Paul Bakaus
UI Architect
--
http://paulbakaus.com
http://www.linkedin.com/in/paulbakaus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---