0

I'm a little confused as to why this newly minted jQuery UI Widget doesn't have an option method?

(function ($) {
    $.widget('ui.oTest', {
        options: {},
        _create: function(){
             $('<span>',{
                 html: 'oTest Span'
             }).appendTo(this.element);
        }
    });
})(jQuery);

$('.test').oTest();
$('.test').option(); //Uncaught TypeError: Object [object Object] has no method 'option' 

Here's the fiddle: http://jsfiddle.net/fwWc8/

Thanks!

1 Answer 1

0

Solution: It's not super clear in the documentation, but options are set using the following:

$('.test').oTest('option', {'string': 'meow'});

http://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.