开发者

Detect if options have been entered in jQueryUI?

开发者 https://www.devze.com 2022-12-25 05:04 出处:网络
开发者_开发知识库Does anyone know how to check if the called ui (custom) has also options input or using the defaults?

开发者_开发知识库Does anyone know how to check if the called ui (custom) has also options input or using the defaults?

For example:

$('#selector').myUI();//does not have options.
$('#selector').myUI({option:'foo',{op:'bar'}});//ui has options.
$('#selector').myUI('value');//ui has options.

So if I was on:

(function($) {
    $.widget("ui.myUI", {
       options = this.options;
       //check if options have been entered or the default values have been used?
    })

});


To check whether an option has been specified, you can write

if (options.hasOwnProperty('someProperty'))


My guess is the only way to find out is to compare them against the default values.

But I'm not that familiar with the inner workings of jQuery.

0

精彩评论

暂无评论...
验证码 换一张
取 消