次の関数に問題があります。私は動的にブートストラップモーダル(regular div)を作成していますが、変数(魔法使いがうまくいく)を渡してon( "hide")を実行する関数をアタッチしたいのですが、代わりにモーダル($(モーダル).on( 'hide'、windowclose_function);)が開きます。私は行方不明のものがありますか?。( 'hide')の動的要素関数を非表示
おかげ
function openModalFromUrl(modal_url, close_function = function(){}) {
var token = $("meta[name='csrf-token']").attr("content");
$.ajax({
data: {
'_token': token,
},
url: modal_url,
type: 'POST',
success: function(html) {
// create a new modal div
var modal = document.createElement("div");
$(modal).addClass('modal fade');
$(modal).attr("role", "dialog");
$('body').append(modal);
// place response in the modal
$(modal).html(html)
// open the modal
$(modal).modal('show');
// THIS FIRES IMMEDIATELY
$(modal).on('hide', window[close_function]());
},
error: function() {
bootbox.alert('Error');
}
});
}
'$(モーダル).on( 'hide'、close_function);'? – PeterMader
'$(モーダル).on( 'hide'、ウィンドウ[close_function]);' remove '()'関数参照を渡すだけです – Satpal