In a plugin I'm writing, the dev can specify options, which I'm storing and referencing like so:
(function( $, window) {
$.widget("mobile.plug", $.mobile.widget, {
options: {
menuWidth: '25%',
middleWidth: '25%',
mainWidth: '25%'
},
some: function(){
var self = this,
o = self.options;
console.log( o.menuWidth );
}
})
}) (jQuery,this);
My Question:
Say I want to loop through all three elements (main, menu, middle) and get the respective option value, how would I construct o.[elem]Width dynamically, if at all possible?
This doesn't work (ERROR: missing name after . operator):
// this selects panels with jqmData(panel="mid|menu|main")
var elems = $('selector');
for (var i = 0; i<elems.length; i++){
var el = elems.eq(i);
console.log( o.[el.jqmData("panel")]Width );
}