Hi all,
I'm having some trouble understanding how to accomplish the following: Basically, I'm just delving into the world of Ajax, and I have built a simple application to practice on. My current problem is that I want to have a form dynamically added below "add entry", so that people don't have to go off to another page to update the page, that part works. Below "add entry", there is a list of all currently added entries, and after the user clicks submit on that dynamically loaded form, i want to update the list below by reloading the page (the list is generated from a database).
To explain the code below, /ajax/addform/ loads an html file, which only have ..., which is the add entry form. I'm just not sure how to bind the $('form').submit to the newly loaded form. Also, for .load(), the second var is POST parameter to the page waiting to be loaded, do i need to use that in order to use the call back (which is the third parameter)?
Here is what i have:
For the initial page:
<a id="add" href=...>Add Entry</a>
<div id="form"></div>
<ul>--list of entries here--</ul>
Where the div is just a placeholder to put the form in.
$(document).ready(function (){
$('#add').click(function (){
$('#form').load('/ajax/addForm/', {'dummy':'var'},
function (){
$('form').submit(function (){
return false;
});
});
return false;
});
});
Thanks a lot for any help!