尝试通过JavaScript显示引导程序模板时IE11中出错 [英] Error in IE11 when trying to show a bootstrap Modal via JavaScript
问题描述
modal.modal(节目);它在所有其他浏览器中工作时触发Internet Explorer中的错误
错误是对象不支持属性或方法'模态'
modal.modal('show'); is triggering an error in internet explorer while it is working in all other browsers The Error is Object doesn't support property or method 'modal'
注意:这个模态由多个按钮调用,每次都需要更新,这就是我进行模态重置的原因。
Note:This modal is called by more than one button and it needs to be updated every time which is why I am doing the modal reset.
在旁注,为什么呢我必须克隆模态两次进行模态重置?有没有更好的方法来重置?
On a side note, why is it that I have to clone the modal twice to do a modal reset? Is there a better way to do the reset?
var original_model = "";
$(document).ready(function() {
original_model = $('#my_modal_id').clone();
})
function show_modal(user_photo) {
//reseting the modal
$("#my_modal_id").remove();
var myClone = original_model.clone();
$("body").append(myClone);
var modal = $("#my_modal_id");
modal.find("#photo").attr("src", user_photo);
// more code to update the modal ...
// Does not work in IE11 : Error : Object doesn't support property or method 'modal'
modal.modal('show');
}
推荐答案
尝试将此代码添加到您的 show_modal()
var modal
声明后的函数:
Try adding this code to your show_modal()
function after the var modal
declaration:
if ($.browser.version > 9){
modal.removeClass('fade');
}
这需要下载 jQuery migrate plugin
这篇关于尝试通过JavaScript显示引导程序模板时IE11中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!