条件文が満たされた場合に追加のボタンを追加するjQueryモーダルがあります。条件付きボタンがjQueryモーダルに追加されました
オリジナルのサンプルコード(切開):
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
}
}).dialog('open');
あなたは上記を参照ようにそこに2つのボタンを持つモーダルですが、私もそこにいくつかの動的なコードを追加したい追加の要求を満たすことができるように変数が設定されている場合はボタンをクリックします。例えば
var some_variable = 0;
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
/* ??? */
if (some_variable==1) //then add the other button's code here..
/* ??? */
}
}).dialog('open');