2012-01-11 52 views
0

我已阅读jQuery UI的可调整大小。之后,我使用代码并取得成功。但现在我不明白该行中的“选项”调整jQuery UI的选项

$(".selector").resizable({ handles: 'n, e, s, w' }); 

Get or set the handles option, after init. 

    //getter 
    var handles = $(".selector").resizable("option", "handles"); 
    //setter 
    $(".selector").resizable("option", "handles", 'n, e, s, w'); 

在这个例子中是什么选项。特别是最后一行$(".selector").resizable("option", "handles", 'n, e, s, w');

+0

我非常抱歉,但我不知道你在说什么。你能形成一个具体的问题吗? – Connum 2012-01-11 12:37:51

回答

2

option is a method。 jQuery UI方法倾向于通过调用窗口小部件函数(在本例中为resizable)以表示方法名称的字符串作为第一个参数来执行。

第二个参数是要获取/设置的选项的名称,第三个参数(如果存在)是设置选项的值。

以类似的方式,你可以启用或禁用窗口小部件:

$(".selector").resizable("enable"); //Call the enable method 
$(".selector").resizable("disable"); //Call the disable method 
$(".selector").resizable("option", "handles"); //Call the option method, get the handles option value 

例如,如果你想知道resizable是否被启用与否,你可以这样做:

//If it's disabled, disabled == true. If not, disabled == false 
var disabled = $(".selector").resizable("option", "disabled"); 

//After the following line, the resizable element will be in the opposite state 
//(if it was enabled, it will be disabled, and vice versa) 
$(".selector").resizable("option", "disabled", !disabled); 
+0

你能举一个例子吗 – Jackson 2012-01-11 12:42:31

+0

一个什么样的例子?你想让我展示什么? – 2012-01-11 12:43:55

+0

我的意思是选项方法的示例 – Jackson 2012-01-11 12:49:46