jquery dialog is clearing my form fields and I need to return a value from a jquery dialog

Posted by Seth on Stack Overflow See other posts from Stack Overflow or by Seth
Published on 2010-06-09T06:43:44Z Indexed on 2010/06/09 7:12 UTC
Read the original article Hit count: 235

Filed under:
|
|
|

1.) I have a jQuery dialog that is opened whenever a particular textbox is focused. The dialog's contents are loaded from ajax and the unique ID of the textbox that was focused is passed in the ajax call (like this):

$('[name=start_airport[]],[name=finish_airport[]]').click(function(){
  var id = $(this).attr('id');
  if($('#use_advanced_airport_selector').attr('checked')) {
    $('#advanced_airport_selector').dialog({
      open : function() {
        $(this).load('/flight-booker/advanced-airport-selector.php?callerID='+id);
      }
    });
    $('#advanced_airport_selector').dialog('open');
  }
});

(where advanced_airport_selector is an empty div)

THAT PART WORKS FINE. However, when I make my ajax call within my dialog, all my form values are reset! No matter what I do, when that dialog opens, all form values are reset (not just the value of the textbox that was focused). I simply don't understand what would cause this behavior!

But that's only issue #1.

2.) I need to be able to return a value from that dialog box. I am passing the ID in the ajax query so that I can use a jquery selector to update the caller's value after certain actions are performed within the dialog box. However, I can't actually access that textbox because of DOM_ERRORS that I've never come across. It doesn't make any sense!

There's way to much code to post, and it's really hard to explain, so sorry if I'm unclear as to what I'm asking.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX