| Page 1 of 2 | [ 11 posts ] | Go to page 1, 2 Next |
|
Hello everyone,
I have a nice web application running with some drag and drop functionality just like the drag&drop example with scrolling http://yuilibrary.com/yui/docs/dd/scroll-list.html. However, my website may change the content of both the <ul> (list1 and list2). How should I approach this? 1. call a function to add a function to create the new li and make it draggable with something like: Code: if(text && id && ul){ var list = document.getElementById(ul); var newNode = document.createElement("li"); newNode.setAttribute('id',id); newNode.innerHTML = text; list.appendChild(newNode); YUI().use('dd-constrain', function(Y) { var newNode = new Y.DD.Drag(newNode); }); } Which doesn't work obviously otherwise I wouldn't ask here 2. recall the complete yui script everytime I change the content. I use to have yui 2 running and had the 1st approach adding these lines was enough: Code: if(YAHOO.example && newNode != 'null') new YAHOO.example.DDList(newNode); Please help me, I would like to have all elements draggable each time I refresh the content of my ul's Thanks in advance. Karsten |
|
You should use the DD.Delegate method instead of creating a DD object per list item.
http://yuilibrary.com/yui/docs/dd/delegate.html Delegate allows for a dynamic list of drag items under a common parent, so you can remove and add children all you want and it still works. |
|
Ah thanks!
That's working. I fitted in: YUI().use('dd-delegate', function(Y) { var del = new Y.DD.Delegate({ container: '#play', nodes: 'li' }); }); but now I see it lost my drop targets (over different UL's) I discovered I need to use delegate.syncTargets(); to sync my drop targets again - all my drop targets are set in the main YUI as ... var uls = Y.all('#play ul'); uls.each(function(v, k) { var tar = new Y.DD.Drop({ node: v }); }); I have tried to use delegate.syncTargets(); in the code above but I can't seem to get it work... please help! |
|
You need to make the delegates targets:
Code: var del = new Y.DD.Delegate({ container: '#play', nodes: 'li', target: true }); del.on('drag:drophit', function(e) { //Handle drop logic here. }) |
|
I'm sorry, I am totally lost.
I thought I had to create a second instance, but appearently the performance goes down drammatically because of the two instances coming into conflict or loop or something. so I need it all to go into one instance and with the Y.one('#make') (but not Click) I can call the function to make the li draggable again like the others? with the following function I'm writing my li with content: function appendOptionLast(text,id,ul){ var list = document.getElementById(ul); var newNode = document.createElement("li"); newNode.setAttribute('id',id); newNode.innerHTML = text; list.appendChild(newNode);} What do I have to append above to make the li draggable again?? The examples on the website doesn't show me what to do with two ul's AND delegate AND proxy AND sorting with scrolling. Here's my YUI code which is basically the example from the website... http://pastie.org/3383717 the only thing I want is refreshing the content of my ul1 and ul2 dynamically (which the site already does - it is creating new li's but I still need to be able to drag and drop on ul1 and ul2 with be able to sorting and scrolling staying in tact. however the new created li's can't be dragged anymore I have puzzled for hours but can't make it work together can you please have a look? Thanks a lot. |
|
I think I'm going in the right direction now.
Can you have a look at my code: http://pastie.org/3390494 all is working - and when I add new li's to the ul1 I can move them over to ul2 the only thing which doesnt work is: after adding new li's - the drop target ul1 seem to fall out, I can only drop it on ul2... after loading the page for the first time - all is working correctly. li's are moving aside when you hold a draggable element above it. but as I said, when I have added new elements (li's), I can move them allright, but li's are not jumping aside anymore on ul1 and I can't drop them on ul1 - and this still works on ul2.... any ideas? Thanks |
|
you haven't given up on me I hope......
here's the exact problem: http://jsfiddle.net/double0seven/5uSrq/5/ add 5 new items and see they're not drop targets anymore... what am I doing wrong here? |
|
I tested this in both FF and IE9, both allowed me to add and drag items, I tried adding over 10 of them and was able to move between both lists.
Are you testing in an unusual or older browser? |
|
Thanks for checking.
I use normal IE9. Steps to reproduce: 1. add 3 new items 2. move item 6 between 4 and 5 Problem statement: new items are not drop targets themselves... and even worse: When you start with an empty list (like I do in my application - it clears the list first) then you won't be able to sort that list at all anymore. See: http://jsfiddle.net/double0seven/5uSrq/7/ |
|
anyone got a chance to have a look?
is this a bug in YUI 3.xx? |
| Page 1 of 2 | [ 11 posts ] | Go to page 1, 2 Next |
| 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