调整jQuery UI的大小选项

时间:2012-01-11 12:35:25

标签: jquery 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' );

1 个答案:

答案 0 :(得分:2)

option is a method。 jQuery UI方法倾向于通过使用表示方法名称作为第一个参数的字符串调用widget函数(在本例中为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);
相关问题