请有人帮忙,我正在尝试将 Cloudsponge 电子邮件小部件集成到 Bootstrap 模式中。
模态的 HTML 如下:
<div class="modal fade" id="invite">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
<i class="fa fa-warning"></i> Invite friends </h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Select how you would like to send an invitation</p>
</div>
<div class="modal-footer">
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
javascript函数如下:
$(document).on("hidden.bs.modal", function (e) {
var activeElement=$(document.activeElement);
if(activeElement.is(".invite")){
excludeCloudSponge();
$("#invite .modal-footer").empty();
}
});
function includeCloudSponge() {
first_script = document.getElementsByTagName("script")[0];
s=\'<script type="text/javascript" src="//api.cloudsponge.com/widget/2xxxxxxxxxxxxxxxxxxxxxxx.js">\';
$(s).insertBefore(first_script);
}
function excludeCloudSponge() {
//var script=\'script[src="//api.cloudsponge.com/widget/2xxxxxxxxxxx.js"]\';
//$(script).remove();
}
function email(){
var wrapper= document.createElement("div");
var ea = document.createElement("a");
ea.setAttribute("class", "cloudsponge-launch");
ea.innerHTML="Add from Address Book";
var et=document.createElement("textarea");
et.setAttribute("class", "cloudsponge-contacts");
wrapper.append(ea);
wrapper.append(et);
return wrapper;
}
$(".invite").click(includeCloudSponge);
问题是每次用户第一次单击按钮时,都会包含脚本并且小部件可以工作,但是当我关闭模式并重新打开小部件时,小部件不再打开。