【发布时间】: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