我有以下功能,它会显示一个可以在
中购买的鱼类菜单.dialog({
title: "Fish Store",
resizable: true,
draggable: true,
modal: true,
buttons: {
"Beard Fish($30)": function() {
if (cash >= 30)
{
fish1 =1;
fish1Swim1();
cash -= 30;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
"Clown Fish($50)": function() {
if (cash >= 50)
{
fish2 = 1;
fish2Swim1();
cash -= 50;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
"Neon Fish($75)": function() {
if (cash >= 75)
{
fish3 = 1;
fish3Swim1();
cash -= 75;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
}
}
});
我想编辑该功能,以便根据变量(fish1,fish2和fish3)打开和关闭按钮。
所以我尝试进行以下更改......
buttons: {
if(fish1=0)
{
"Beard Fish($30)": function() {
if (cash >= 30)
{
fish1 =1;
fish1Swim1();
cash -= 30;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
}
但是我的文字编辑说语法无效,我怎么能让这个工作?
答案 0 :(得分:2)
我认为好的方法是:
$( ".selector" ).dialog( "option", "buttons", { "Ok": function() { $(this).dialog("close"); } } );
第3步:显示对话框