Hi,

The fragment you've quoted shouldn't be replacing the content of the
link. It's getting the link element

    $(link)

then going to its parent element

   .up()

then inserting content *after* the parent element

   .insert({after: ...})

The link should remain intact, nothing should be replaced, just
something new added immediately after the link's parent element.

If you want to insert something inside the link element, do this:

    $(link).insert({ ... });

For instance, to add something at the end of the link (but inside it):

    $(link).insert({bottom: "stuff here"});

If you've inherited a Prototype-based project, it may be worth
spending just an hour or so reading through the API docs (literally
takes about that long, it's not massive undertaking):

The new API docs:
http://api.prototypejs.org

The old API docs (which sadly still have some content that isn't in
the new ones, but people are busily transferring content over):
http://prototypejs.org/api

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Feb 27, 8:41 pm, Grary <grary.sti...@gmail.com> wrote:
> Hi,
>
> I've inherited a project with some Prototype connections I do not
> understand.
>
> To wit, I'd like to modify the following javascript function so that I
> can append to the link element, not replace the content:
>
> function add_fields(link, association, content) {
>         var new_id = new Date().getTime();
>         var regexp = new RegExp("new_" + association, "g")
>         $(link).up().insert({
>                 after: content.replace(regexp, new_id)
>         });
>
> }
>
> Any suggestions?
>
> Thanks,
>
> Grar

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to