2012-01-11 95 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