JQuery: Dynamically-generated form fields not submitted and event handlers appear to fire multiple t

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-03-17T12:38:40Z Indexed on 2010/03/17 12:41 UTC
Read the original article Hit count: 370

Filed under:

Hi,

I'm new to JQuery, so I apologise if there's something which should be obvious which I'm unaware of. I seem to be having a couple of issues some JQuery I'm trying to implement:

Code: http://pastebin.ca/1843496 (the editor didn't seem to like HTML tags)

post_test.php simply contains: [?php print_r($_POST); ?] in an attempt to find out what's actually being submitted.

The first issue I'm having is that only the hidden form fields are actually being submitted. If I insert tags into the container DIV manually it works as expected, but when done as above the text field doesn't get posted. From what I've read, I gather it's to do with the fact that the DOM is being modified after it's loaded, but the thing that's puzzling me is why, in that case, there are no issues referencing the other added hidden fields or the tag. I've experimented with changing the event handler for a.save to '.live('click', function ...' and also using LiveQuery to no avail.

The other issue is that when a.save is clicked, before the form is actually submitted, as far as I can tell the event handler is running again, replacing the value entered into the text field with the value of editable.text(), which is what ultimately gets submitted.

I'm sorry if any of this is unclear.

Regards,

© Stack Overflow or respective owner

Related posts about jQuery