I am switching from using Mootools to just Prototype, because I
couldn''t get Mootools ajax and TinyMCE to play together.
I want to copy an element, change one of the attributes of an element
inside of IT, and then insert it under the first element. (Making a
form where you click to add another field)
This is what I got so far for the JS:
$(''addAlbum'').observe(''click'', function(){
var p = $(''albumDiv'').firstDescendant();
$(''albumDiv'').update($(''albumDiv'').innerHTML+p.innerHTML);
});
Where addAlbum is the button you click to add one, albumDiv is the div
with the label and input in it.
How would I go about getting the input element, changing it''s name and
ID, and inserting it? Is there a better way than what I have started?
Thanks for help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
ityndall-ue636x8T32g@public.gmane.org
2007-Dec-12 15:18 UTC
Re: Copy an element and insert it.
How about:
$(''addAlbum'').observe(''click'',
function(){
var p = $(''albumDiv'').firstDescendant();
var albumNew = p.cloneNode(false);
$(albumNew).writeAttribute({id: ''newid'', name:
''newname''}).update(''Album Two'');
$(''albumDiv'').insert(albumNew);
});
On Dec 12, 9:48 am, jesirose
<jesir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I am switching from using Mootools to just Prototype, because I
> couldn''t get Mootools ajax and TinyMCE to play together.
>
> I want to copy an element, change one of the attributes of an element
> inside of IT, and then insert it under the first element. (Making a
> form where you click to add another field)
>
> This is what I got so far for the JS:
> $(''addAlbum'').observe(''click'',
function(){
> var p = $(''albumDiv'').firstDescendant();
>
$(''albumDiv'').update($(''albumDiv'').innerHTML+p.innerHTML);
>
> });
>
> Where addAlbum is the button you click to add one, albumDiv is the div
> with the label and input in it.
> How would I go about getting the input element, changing it''s name
and
> ID, and inserting it? Is there a better way than what I have started?
>
> Thanks for help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---