0

I've created (or am trying to create) a jQuery UI widget using the widget factory and have set up my _setOptions method this way as found here: http://wiki.jqueryui.com/w/page/12137708/How%20to%20use%20jQuery%20UI%

_setOptions: function (key, value) {
    if (this.options[key] !== value) {
        this.options[key] = value;
        this._update();
    }
},

This is my options object:

 options: {
            title: 'Legend',
            colors: ['#0000CC', '#6600CC', '#009900', '#990000', '#6600FF', '#CCFF00', '#FF9900', '#000000', '#FFFFFF', '#00FF00'],
            items: undefined
        }

However, when I pass in a new title value for my legend widget, I am getting an object for key instead of a key and value in _setOptions. value comes in undefined, for the record.

$('#myLegend').legend('option', 'title', 'New Title');

The key object

My expectations were this:

key==='title'
value==='New Title'

If there some common misconception I'm missing or can anyone think of why this would be happening?

1 Answer 1

1

The _setOptions method does get called with an object for the first argument, it contains key/value pairs of all the options changed.

http://api.jqueryui.com/jQuery.widget/#method-_setOptions

what you probably meant to use was _setOption rather than _setOptions

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

1 Comment

Dammit. Instead of accepting blame, I will place blame on the fact today is Monday. Thanks, Kevin.

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.