【问题标题】:tabindex conflict between Alertify and bootstrap 4 modalAlertify 和 bootstrap 4 模式之间的 tabindex 冲突
【发布时间】:2021-09-11 05:11:45
【问题描述】:

我在运行 Bootstrap 4 模态时调用了一个 Alertify Confirmation 对话框,问题是选项卡焦点在第一个不工作,而在最后一个。

我相信这与“tabindex=-1”有关...

我认为可行的概念之一是在 Alertify onshow 和 onclose 事件期间从“modal”类 div 元素切换“tabindex=-1”,但仍然无法正常工作!

    let mymessage = "Update entry?";   
    alertify.confirm().set({title: "Confirm!"})
        .set({labels: {ok:"Yes", cancel:"No"}})
        .set("defaultFocus", "ok");
        .set({onshow:function(){$(".modal").attr("tabindex","-2");}})
        .set({onclose:function(){$(".modal").attr("tabindex","-1");}}); 
    // Show confirmation message
    alertify.confirm(mymessage, function(e){
            if(e){
                editRow();
            } else {
                alertify.notify("Entry update has been canceled!");
            }
        }).bringToFront(); 

看看在 Alertify Confirmation 对话框中缺失的 Tab 序列是否仍在 Modal Div 中!

感谢您的支持!

【问题讨论】:

    标签: javascript html jquery bootstrap-4 alertify


    【解决方案1】:

    以下代码解决了这个问题:

        let mymessage = "Update entry?";   
        // custom OK and Cancel label to Yes and No
        alertify.confirm().set({title: "Confirm!"})
            .set({labels: {ok:"Yes", cancel:"No"}})
            .set("defaultFocus", "ok")
            .set({onshow:function(){$(".modal").removeAttr("tabindex");}})
            .set({onclose:function(){$(".modal").attr("tabindex","-1");                            
            }}); 
        // Show confirmation message
        alertify.confirm(mymessage, function(e){
                if(e){
                    editRow();
                } else {
                    alertify.notify("Editing entry has been canceled!");
                }
            });
    

    【讨论】:

      猜你喜欢
      • 2014-09-13
      • 2014-03-02
      • 2016-06-27
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多