Reputation: 5989
I do some debugging and I found this statement:
$(this)[widget.widgetName](widget.attributes);
where widget.widgetName = chart
What is the meaning of this statement in jquery?
In the stack I saw that jquery_ui calls _createwidget of jquery-ui
Why does createwidget get called ?
Regards, Yossi
Upvotes: 1
Views: 74
Reputation: 116
$(this)[widget.widgetName]
refers to the propert of $(this) defined by widget.widgetName
in this case it is simply
$(this).chart
Upvotes: 2
Reputation: 75317
$(this)[widget.widgetName]
uses square bracket notation to refer to the property whose value is the value of widget.widgetName
. For comparisons between square backet and "dot notation" see the MDC article.
As you said widget.widgetName
is chart
, it's refering to:
$(this).chart
and then the (widget.attributes);
is simply invoking the function and passing widget.attributes
as the first and only parameter:
$(this).chart(widget.attributes);
As for "Why does createwidget get called?" The chart()
function must call it, either implicitly (through another function) or explicitly.
Upvotes: 2
Reputation: 53311
$(this)
refers to a jQuery object. In this case, you're inside an event handler, element selector, or some other sort of jQuery context where $(this)
refers to to the jQuery object in the outside selector.
Upvotes: 0