rgiri (8) [Avatar] Offline
#1
I am trying to incorporate what's in chapter 8 in my experiment page.



I have a parent-child table data entry form. For example order and order entry. In the same JSP I have the html layout as -

1) preview your order plus items in a table

2) order form

3) order entry form (using .load to populate the empty div on add button click - trying out how getDetails.jsp is populating boot closet example)



In the preview section - I have added a button "add_value" which using .load() populates the empty div for the order entry form(which is another JSP).



When the first time the page loads - if I click on the add button the page shows up always in the empty div.



Once I submit data with order form and come back to this page - my "add_value" clicks stops working. I can see that the function is getting called but no interaction with server happens. As if the the empty div id is absent from the DOM.



I searched the jqueryhelp "I am stuck" section - which talks about re-binding but I am not sure if the same argument applies to the above scenario since there is only one "add_value" button and after the ajax completes I am not adding any more new such "add_value" id which needs re-binding.



Can anyone please help me - I am not moving forward after the first click.




<script>

 $ (function() {
 	$('#add_value').click( function() {
 	   alert("inside click");
 		$('#descriptor_value').load(
 			 'descriptorValue.jsp', function(){return false;});
 	})
 }); 

</script>
>> snipped<<

In the preview pane - Add button looks like -

<td colspan="6"><input type="button" id="add_value" name="add" value="Add Value"/></td>

Further down below in the JSP I have an empty div

<div id="descriptor_value"></div>

where I am trying to populate the child data form.



Any help is much appreciated.



Thanks,

Rumpa Giri
bear.bibeault (675) [Avatar] Offline
#2
Re: .load stopped working after form submission
> I can see that the function is getting called but no interaction with server happens. As
> if the the empty div id is absent from the DOM.

When I'm seeing things that don't seem to make sense, I've found that inspecting the Ajax request and the DOM tree using FireBug in Firefox is the most essential tool to use. With it, you will be able to see if your Ajax calls are firing (and the details regarding them), and to inspect the DOM in real time, including any changes made with script (not possible with View Source).

Maybe that will help you shake something loose.
rgiri (8) [Avatar] Offline
#3
Re: .load stopped working after form submission
You are a life saver!!!!!!!!!

Forgot to add why it stopped working -
I should have added the absolute URL in the load since after the form post the URL changed and its trying to find out the JSP under the current forlder structure.

Thank you for replying so quick - since yesterday I am trying to register to forums to just post with no luck smilie then it dawned upon me I should post it in here since I am reading the book.. duh. Should have done it yesterday..

I love your book.. its not at all intimidating at all unlike other javascript books..

Thank you again,
Rumpa Giri

Message was edited by:
rgiri
bear.bibeault (675) [Avatar] Offline
#4
Re: .load stopped working after form submission
My pleasure. And thanks for the feedback on the book!