views:

30

answers:

2

Hi,

I am having some issue with the enter key within IE6 together with the jQuery UI Dialog confirmation box that has just an "Ok" button on it.

$("#myBox").dialog({
            autoOpen: false,
            closeOnEscape: false,
            resizable: false,
            modal: true,
            draggable: false,
            position:  ["center", 100],
            buttons: {
              'Ok': function() { 
                      $(this).dialog("close"); 
                      closeReq();
                    }
        }
    });

Basically, I only want the dialog box together with any additional function calls against the "Ok" to close/fire function, only when the user clicks on the "Ok" button.

At the moment, I allow the user to press the "Enter" to fire off the retrieval of some info and then based on some validation of this data, I produce a modal jQuery UI dialog box but seems to autmatically close from the user's pressing of the "Enter Key" from the start.

How can I prevent this from occuring, i.e. deactivate the "Enter" key in IE6 for this jQueryUI Dialog Message box?

Thanks.

A: 

At the moment, I allow the user to press the "Enter" to fire off the retrieval of some info and then based on some validation of this data

whereever you do that, call

.preventDefault();
.stopPropagation();

within your event handler. Returning false is like a shortcut for that.

jAndy
sorry jAndy, didn't work for me. By still pressing enter, goes through the motions and also removes the dialog without allowing the user to acknowledge the "OK" button. Is there anything in the buttons that can be done?
tonsils
A: 

Managed to track this down which solved my problem, pls refer to: see solution

Looks like preventDefault is not recognized by IE6

Thanks to @jAndy for your assistance.

tonsils