| Page 1 of 1 | [ 9 posts ] |
|
Hello,
I am trying to build a little search engine, where the results of every search are retrieved through an AJAX call and are presented in a pageable list (10 items per page) similar to those of a webmail system. I want every single result item to be selectable only by clicking on it and, at the same time, draggable to a folder list, in other words, organizable. In order to make the items selectable, I attach a "click" event listener to every LI element after the paged results are retrieved. (I detect whether the UL parent has the "multi-selectable-list" class and if the LI child element has the "selectable" class, an event is attached.) And... after that, to make the LI elements draggable, I attach a DD.Delegate to the parent UL element in a different part of the JS/YUI code. I need those things to happen in two times, because in my application not all selectable items are always draggable, and not all draggable items are always selectable. But this approach gives me a headache: 1) The first problem is the DD.Delegate overrides the select click event listener. How could I detect if an item was only clicked (in order to change its class to "selected") or if it was dragged and droped into a folder? 2) The second problem is... I attach the DD.Delegate to the UL list every time the results are updated. Therefore, when an item is dragged, the listeners are triggered two times after the second update, three times after the third, and so on... Is it possible to detach all the events from the DD.Delegate and then reatach them? I have tried it with detach() and detachAll() but it seems to do nothing on my DD.Delegate dom element. Any ideas? Thanks in advance, - Oriol - |
|
You can set the haltDown config option to false and DD will not swallow the mousedown event: http://yuilibrary.com/yui/docs/api/clas ... r_haltDown
As for Delegate, it's designed so that you don't need to keep destroying it and recreating it. Since the parent is never destroyed the delegate does not need to be touched. The items underneath the Delegate container can be totally dynamic. Delegate does not attach any events to the children of the container, it listens for them at the container level and then dynamically makes that child draggable. So you can destroy all the children and create new ones (from an XHR request) and Delegate will still work with no changes to it at all. |
|
I have a similar problem
i have attach click listeners on my drag elements Code: var dd = new Y.DD.Drag({ node : node, haltDown:true }).plug(Y.Plugin.DDProxy, { moveOnEnd: false, cloneNode:true }).plug(Y.Plugin.DDConstrained,{ constrain2node : document.body }).plug(Y.Plugin.DDWinScroll); and then on dd i have all dd.on('drag:start').... events registered my problem is when i test on ipad the click on drag elements doesn't work. but on safari browser on my desktop it works. what should i do ? |
|
I haven't tested a 'click' on a 'dd' element on a touch device. This can be a really really messy interaction since a mousedown with a move (on a touch device is pretty easy to do) will mess with your interaction.
My recommendation is to not do that and really look at your interaction to see if clicking on and dragging the same element (without handles) is a good idea. |
|
i need to do many things when my drag elements are touched, apart from drag drop.
why is drag drop utility not bubbling the click event on drag element? is this a bug ? any other workarounds ?? |
Juan Ignacio DopazoYUI Contributor
|
But clickable and draggable elements are really common. Just look at Windows. You can click an icon and drag it.
|
|
Like I said, it's likely an iOS thing since it "jacks up the mouseevents into a touch event", then file a repro case. I personally don't think it's a bug when it comes to iOS.
I can see your point on Windows. But look at iOS, to move something (icon for example) you must hold it for a couple of seconds then you are allowed to move it. Same principle would apply here. They don't want you doing that interaction because it's not "right" for a touch device. |
|
if i have like 50 drag element in the DOM.
and the DD.Proxy is already instantiated over them how do i initiate drag:start when user holds over drag element ? so that touch and drag are two distinct operation. can u suggest any other way do do touch and drag on hold ? |
|
I wanted to do similar functionality so I disabled drag based on thresh pixel. Drag starts only when time thresh is met. I modified dd-drag for this.
|
| Page 1 of 1 | [ 9 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group