好吧,我花了整整一天的時間閱讀Q & A但仍無法完成。我需要創建一個自定義的確認(),其中,而不是默認的對話中,我使用的引導模式,如果用戶點擊Yes(是)返回true,對於號返回falseBootstrap Modal - 如果單擊是按鈕時返回True - 定製確認
例子:
<a href="remove.php?id=3" onclick="return custom_confirm('Are you sure you want to remove this?');" />
和我自定義的確認功能是:
function custom_confirm(message) {
// put message into the body of modal
$('#modal-custom-confirmation').on('show.bs.modal', function (event) {
// store current modal reference
var modal = $(this);
// update modal body help text
modal.find('.modal-body #modal-help-text').text(message);
});
// show modal ringer custom confirmation
$('#modal-custom-confirmation').modal('show');
// if Yes button is clicked, return true
// if No button is clicked, return false
// logic here...
}
我的模式是在這裏:
<!-- modal: custom confirmation -->
<div class="modal fade text-left" id="modal-custom-confirmation" tabindex="-1" role="dialog" aria-labelledby="modal-help-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong class="modal-title" id="modal-help-title">Confirm</strong>
</div><!-- /.modal-header -->
<div class="modal-body">
<p id="modal-help-text"></p>
</div><!-- /.modal-body -->
<div class="modal-footer">
<button type="button" class="btn btn-success">Yes</button>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
過去發生在我身上的事情,最後我不得不使用http://bootboxjs.com/之外的庫。 –
@TranAudi,謝謝!你在這裏釘了它:http://bootboxjs.com/examples.html#also-applies-to-alert-prompt-customwith-alternate-button-tex –