Thursday, March 31, 2011

get one Attribute id, set as another Attribute id

I'm currently using scriptaculous and prototype to drag/drop elements from one div to another, and append a new Element based on the 'src' of the element that is dropped, creating a new draggable out of it.

What I need to do is assign the id of the dropped element to the new one once it is created.

I've tried a ton of different approaches, here is the latest:

$$('.image').each(function(stack) {
new Draggable(stack, { revert: true, ghosting: true }); 
});

...

onDrop: function(stack) {
      var added = new Element('img');
      added.src = stack.readAttribute('src');
      var imageid = stack.identify();
   added.setAttribute('id', imageid);

obviously I'm a bit of a novice, and imagine I am way off by now. Appreciate any help.

From stackoverflow

0 comments:

Post a Comment