开发者

jQuery widget options array

I'm making a roulette widget using jQuery widget factory (see it at http://stuff.manisto.dk/roulette/). To make it easier for people to use, I specify some default options, such as the elements.

The problem is, when I specify an element array that is smaller than the default options (see http://stuff.manisto.dk/roulette/?elements=stack;overflow), the remaining elements are still displayed.

How to fix this? And wh开发者_高级运维y does jQuery copy all of the array values instead of supplying the new array, if one is specified?

By the way, you can view the code at http://bitbucket.org/manisto/jroulette/src.


That's because using jQuery's extend method you just "overwrites" the elements that are present in the array that extends the original (options). If you want to get rid of the other elements simply don't extend the original or nullify them in that you provide these with a value of null or undefined in the extending array.

I haven't looked at your code but I know that in general default options in jQuery are extended by what the user sets on a per call basis.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜