【问题标题】:Uncaught (in promise) TypeError: Cannot read property 'template' of null popover.jsUncaught (in promise) TypeError: Cannot read property 'template' of null popover.js
【发布时间】:2019-07-23 23:29:48
【问题描述】:

当我触发.popover('dispose'); 函数时,我注意到一个错误,当我向上和向下滚动页面时会发生错误,它会减慢我的页面速度。该函数按应有的方式运行并关闭弹出框,但这是错误Uncaught (in promise) TypeError: Cannot read property 'template' of nullpopover.js ]1]1

我的功能

$('#country').focus(function (e) {
    e.preventDefault();
    $("#country").popover('hide');
    $("#country").popover('disable');
    $("#country").popover('dispose');
});

我已经实现了一个动态弹出框,我需要添加一个类似于上面的函数来关注输入字段,因为弹出框消息在完成其工作后不断出现。

var allCountries = ['a', 'b', 'c', ...];
var mispelledCountryMsg = "misspelled error message...";

$('#country').focusout(function (e) {
    e.preventDefault();
    $.each(allCountries, function (x) {
       if (inp.value !== allCountries[x]) {
            $('[data-toggle="popover"]').popover();
            $('#country').attr('data-content', mispelledCountryMsg).popover('show');
            disableFormFields();
       } 
    });
});

【问题讨论】:

    标签: jquery twitter-bootstrap bootstrap-4 bootstrap-popover


    【解决方案1】:

    尝试使用 {'trigger': 'manual'}

    $('[data-toggle="popover"]').popover({'trigger': 'manual'});
    

    【讨论】:

      猜你喜欢
      • 2019-08-08
      • 2021-07-29
      • 1970-01-01
      • 2019-02-12
      • 2021-09-20
      • 2021-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多