[英]Bootstrap / Modal alert - log shows with no alert
基本上,我正在使用的擴展名應該在單擊時顯示一個警告框。 但是,該按鈕可以通過執行下一步“跳過驗證”來完成它的工作,而無需顯示該框。
單擊按鈕后,我從控制台收到了回信。
$("#usps_skip").click(function() {
console.log("skipCLicked");
var msg = "No address information will be stored with the Contact record if you skip USPS verification. Do you still wish to skip the USPS verification step?";
$('#errorModal .modal-body').html(msg.split('\n').join('<br />'));
$('#errorModal').modal('show');
});
控制台中將顯示“ skipCLicked”日志,但是沒有出現實際的模式消息警報。 有什么建議么?
以下是我在chrome擴展程序中的代碼。
js代碼
switch(ObjField.id) { //other case code removed since it is not necessary case "usps_skip": str_field = str_field + '<button class="btn btn-danger" data-target="#errorModal" name="'+ObjField.name+'" id="'+ObjField.id+'" value="">'+ObjField.label+'</button>'; //str_field = str_field + '<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#errorModal" name="'+ObjField.name+'" id="'+ObjField.id+'" value="">'+ObjField.label+'</button>'; break;
模態/ tabs.htm
<div id="errorModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Error</h4> </div> <div class="modal-body"> <p></p> </div> <div class="modal-footer"> <button type="button" id="modalSkip" class="btn btn-success" data-dismiss="modal">Skip Verification</button> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> </div> </div> </div> </div>
該按鈕可以正常工作,但不會顯示任何消息,將不勝感激。
編輯:console.log(“ skipCLicked”); 通過控制台顯示,因此可以正常工作。
你試過了嗎:
$('#myModal').on('shown.bs.modal', function (e) {
console.log('is modal open?'); // does it shown in console? if not then modal is not open.
// do something... like $('#errorModal .modal-body').html(msg.split('\n').join('<br />'));
});
PS。 如果console.log('是否是模式打開的?')在控制台中顯示,那么您必須檢查為什么模式是不可見的。 可能有很多原因,沒有高度/寬度,z-index低等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.