EasyUI Forum
September 13, 2025, 12:28:02 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Escape from Modal window  (Read 11590 times)
korenanzo
Guest
« on: April 13, 2016, 09:01:22 AM »

Hi,

I've found that you can escape from a modal window, if someone or something gives the focus to a blocked object

try this

http://code.reloado.com/oeasyrik1/2/edit#preview


Is there a way to avoid it?

I think so, because the overridden jQuery().dialog() works fine

http://code.reloado.com/oeasyrik2/2/edit

Thanks, RIc
« Last Edit: April 13, 2016, 09:42:31 AM by korenanzo » Logged
korenanzo
Guest
« Reply #1 on: April 19, 2016, 08:57:58 AM »

no chance to fix it?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: April 20, 2016, 01:19:30 AM »

Please look at this topic http://www.jeasyui.com/forum/index.php?topic=5693.0
Logged
korenanzo
Guest
« Reply #3 on: April 20, 2016, 01:39:22 AM »

it was me again  Grin

anyway the problem I am describing is similar but not the same

I mean, watchTab() resolves partially the problem

In fact, even with watchTab activated, I can do

$('#t').textbox('textbox').focus()

so the modal dialog loses the focus.

As you can see in the other example,this does not happen with the jQuery.ui.dialog
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: April 20, 2016, 11:59:58 PM »

Please try to call this 'watchTab' method.
Code:
(function($){
    $(function(){
        $(document).unbind('.watchTab').bind('focusin.watchTab', function(e){
            var ww = $.fn.window.mwindows || [];
            if (ww.length){
                $('#'+ww[ww.length-1]).focus();
            }
        });
    });
    $.fn.window.mwindows = $.fn.window.mwindows || [];
    var WININDEX = 1;
    $.extend($.fn.window.methods, {
        watchTab: function(jq){
            return jq.each(function(){
            var target = this;
                var opts = $(target).window('options');
                if (!opts.modal){return;}
                var onOpen = opts.onOpen;
                var onClose = opts.onClose;
                $(target).window({
                onOpen: function(){
                        if (opts.modal){
                            var id = $(this).attr('id');
                            if (!id){
                                id = '_windows_'+WININDEX++;
                                $(this).attr('id', id);
                            }
                            $.fn.window.mwindows.push(id);
                            $(target).focus();
                        }
                onOpen.call(this);
                },
                onClose: function(){
                        var index = $.inArray($(this).attr('id'), $.fn.window.mwindows);
                        if (index >= 0){
                            $.fn.window.mwindows.splice(index,1);
                        }
                onClose.call(this);
                }
                });
                $(target).attr('tabindex','-1').css('outline',0).unbind('.watchTab').bind('focusin.watchTab', function(e){
                return false;
                }).bind('keydown.watchTab', function(e){
                    if (e.keyCode == 9){
                        var first = $(this).find(':input:enabled:visible:first');
                        var last = $(this).find(':input:enabled:visible:last');
                        if (e.target == last[0] && !e.shiftKey){
                            first.focus();
                            return false;
                        } else if (e.target == first[0] && e.shiftKey){
                            last.focus();
                            return false;
                        }
                    }
                })
            })
        }
    })
})(jQuery);
Logged
korenanzo
Guest
« Reply #5 on: April 21, 2016, 10:41:19 AM »

kudos!!  Cool Cool Shocked Shocked

Logged
korenanzo
Guest
« Reply #6 on: April 22, 2016, 03:42:38 AM »

Please try to call this 'watchTab' method.


One more thing...
how to include the buttoner buttons in the tab loop?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!