0

我需要检查页面加载的值,以确定对话框是否应该自动打开。我想这将类似于处理关闭的方式,但事实并非如此。

$(".x_dialog").dialog({
                autoOpen: function(){ret();}
});

 function ret() {return false;}
4

2 回答 2

1

autoOpen 只能接受truefalse。在初始化对话框之前计算值

var autoOpen = (1 === 2);

$(".x_dialog").dialog({
    autoOpen: autoOpen
});

或者,您可以将其设置为函数的返回值,但该函数必须返回一个类似布尔值的值。

$(".x_dialog").dialog({
    autoOpen: ret() // note the `()`, this means the function gets executed immediately
});
于 2012-10-19T19:01:08.613 回答
0

我的方法是错误的。

页面加载后,检查条件,然后调用

$("#x_dialog").dialog("open");

如果合适的话。

于 2012-10-22T13:45:39.883 回答