Refresh (F5) doesn't work in jQuery dialog

I am using a jquery dialog widget to display a modal window. However, when you press F5 while the modal mode is open, the update does not occur. Any idea?

Interesting update:

Try this demo: http://jqueryui.com/demos/dialog/#modal-message Now that the focus is on the ok button, it is updated (F5), however, when the button has no focus, then it is not.

Update 2

In fact, we can simply add some control to the dialog, set the height and width to 0 css and set the focus on it to get an update. However, this is not the best solution. I'm still trying to get the keys to work.

Update 3

The following seems to work now:

$(document).keydown(function(e) { if (e.which == 116) // key code of the F5 button { document.location.reload(); } }); 
+7
jquery jquery-ui jquery-dialog
source share
4 answers

This seems to be a common problem, and I did not find a satisfactory answer. There are a few similar questions about stack overflows and the best answer I've seen is to grab the keys and initiate the action yourself (this was for the login launching the button, so f5 could be more difficult to update). I saw this myself in a project that I am working on too.

I suspect setting modal to false might help, but I haven't tried it yet.

Edit:

I found this on line 539 of ui.dialog.js:

 events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), 

Removing the keys and pressing the keys there seemed to allow the usual browser keys to work. Now mine looks like this:

 events: $.map('focus,mousedown,mouseup,click'.split(','), 

I do not know what functionality I would remove by doing this. The only events of the place seem to be on line 549:

 $(document).bind($.ui.dialog.overlay.events, function(event) { var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0; return (dialogZ > $.ui.dialog.overlay.maxZ); }); 

It would be nice if this were fixed in the official version.

+6
source share

Does the dialog expand the F5 key, capturing the key press event and stopping it from spreading to "F5"?

Check out the code for keystrokes of this type. That would explain a lot!

0
source share

I had similar problems, but I found that I put "return false", which stopped all other registered keys. For example, "return false" below will stop all other keys (for example, F5) that will be recognized, except for xxx and yyy.

 $(document).keydown(function(e){ if (e.keyCode == xxx) {/*do something*/} if (e.keyCode == yyy) {/*do something*/} return false; }); 

So just pull out "return false".

0
source share

The solution is easy, you just need to focus on the form element of your modal dialog box. More information about this link :

0
source share

All Articles