I'll try to explain what I am up to; feel free to slap me if I am
really messing this up.

I have a table that represents orders in a database, and it seems to
be working fine.  When the user clicks on an order a div is updated
using an Ajax.updater call.  This works well, the information is some
html code that gives details of the order.  It includes an edit link,
and when the user clicks this another Ajax.updater updates the same
div - this time with a form.  That seems to work will to.

Here is the problem that I am running into.  When the submit button is
clicked, I want the data to be saved and the div to by updated again
with the refreshed order details.  I can't seem to come up with a way
that works.

I have tried attaching an "onSubmit" observer to the form, but it
doesn't seem to work.  In the edit link I had to wimp out and actually
use an "onClick=editOrder(OrderID)" right in the <a> tag.  That won't
really work with the form submit...or probably it will but "I" haven't
been able to make it work.

At this point, I know there is a better way.  Could anyone share it
with me?

The other question I have is how to attach an observer to a
dynamically created element - like my form?

Here is one of the many things that I have tried - this function is
called at the end of the function that updates the <div> with the form
for editing:

function detailChanges() {
    if($("editOrder") != undefined) {
        $('editOrder').observe('submit', saveOrder)

    if ($('editDate') != undefined) {
        var opts = {

"editOrder" is the id and name of the <form> while the "editDate" is
an <input> passed in with the rest of the form.  "editDate" will be
found (though getting the datepicker to work is a thread for another
day) but the "editOrder" form is never found.

Thanks for any help.


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-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to