chdzma
chdzma

Reputation: 191

How to access $.widget options values?

I need to access to the inside of the widget and get the options values, in this case the sizeId.

 $.widget('mod.sizecurves', {
    options: {
        sizeId: 0,
        jsonUrlInfo: '',
        jsonInfo: {}
    },

    getSizeId: function(){
        return this.options.sizeId;
    }
});


var sizeId = $.mod.sizecurves('getSizeId');

console.log(sizeId);

In the console I receive an object and i want to only receive the value of sizeId.

enter image description here

Upvotes: 2

Views: 170

Answers (1)

Richard
Richard

Reputation: 1048

The object you get is a json. You have to parse it then access to the wanted param, like so

var obj = $.parseJSON(sizeId);
console.log(obj.options.sizeId);

Upvotes: 1

Related Questions