views:

25

answers:

1

I am having one hell of a time trying to get this to work, no javascript errors what so ever. Its just going right to the action. Here is the javascript I am using

$(function(){

      $("form[name=form1]").submit(function(){
          return $("#dialog").dialog({
              autoOpen:false,
              bgiframe: true,
              resizable: false,
              //height:auto,
              width:500,
              modal: true,
              overlay: {
                  backgroundColor: '#000',
                  opacity: 0.5
              },
              buttons: {
                  'I Agree': function() {
                      $(this).dialog('close');
                      return true;
                  },
                  'I Do Not Agree': function() {
                      $(this).dialog('close');
                      return false;
                  }
              }
          });     
    });         

});

A: 

The problem is that the dialog method you are calling returns immediately and the buttons functions are called asynchronously, when the buttons are clicked. I suggest that you attach a simple click event to your submit button. The click event will open the dialog and the 'I agree' function will submit the form.

kgiannakakis
I added a click function to it, http://pastie.org/private/5z0cqb5zf7o2jqmjgyfjea and made the button have an id of #button, nothing happens at all.
mikelbring
If #button is a submit button, add a 'return false;' to the end of the click handler to avoid submission. Other than that, I see no problem with your code. You may want to try Firebug to see what is happening.
kgiannakakis