This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JQuery.UI Dialog & $().load() & JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "JQuery.UI Dialog & $().load() & JavaScript" Watch "JQuery.UI Dialog & $().load() & JavaScript" New topic
Author

JQuery.UI Dialog & $().load() & JavaScript

Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

On an event I am showing a JQuery.UI dialog. The way JQuery.UI Dialog works is it expects an existing DIV to simply transform into the dialog. I need a form in the dialog but I need it populated and shown via ajax. So here is how I go about doing that.



Note that the following line...



...takes the DIV element I created and performs an AJAX request to get the desired HTML. That HTML looks like...



This works. Note that now I have a script being loaded for this html. This code is where the problem eventually occurs. The first time I show the dialog everything works. There is a text field and a button. I enter something in the text field and hit enter or click the button and that value is submited via AJAX to the server and a table in the dialog is updated. However, subsequent times showing the dialog part of the script isn't working but no errors are being thrown.



The saveSynonym() function is always called. if I alert the lengh of $('#synonym\\.name') it is always 1 so I know it is only finding one element. However, $('#synonym\\.name').val() is coming back empty. Normally, that would trigger the error portion of the code. But the error isn't showing up either.

Just to reiterate, the first time the dialog is shown everything works as expected. Subsequent times it does not.


My Blog | DZone Articles
 
 
subject: JQuery.UI Dialog & $().load() & JavaScript
 
Threads others viewed
jQuery AJAX display issue
Problem on getting values from a radio buttons group
Can't get RequestDispatcher forward() method or response.sendRedirect() to work
document.forms[0].submit(); throws Invalid Argument in IE
Is it possible to put a button inside autocomplete in jquery ui plugin?
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture