Response title
This is preview!
I am developing a framework of jquery
widgets for a new project. They are created by the
$.widget
factory and they work well using
$("selector").myWidget(myOptions).
I want to avoid possible name collisions and prefer using the form
$.myNamespace.myWidget(myOptions,
mySelector)
, but an error is thrown when the selector
matches no element on page:
owner is
undefined, that I traced to the line 3649, on
jquery-2.2.0 (function
acceptData).
For reference, I've already read (and I think I understood):
This question was also posted on stackoverflow.
Do you have any thoughts?
I read that using method of that widget invocation gets strange as well. Is that still true?
This enables me to code $(".foo").pancake.syrup("maple"). Could something like this be incorporated into the widget factory?
Getting back to the OP’s question, They have to make sure they pass a selector that matches something.
it passes a jquery object, but could be easily changed to pass its corresponding element
Otherwise, I solved my problem overriding the method _createWidget on my base class:
Is it a supported practice or should I create some helper method to create my widget instances?
is there a way to use the syntax $("selector").myWidget(myOptions) with namespace?
© 2013 jQuery Foundation
Sponsored by and others.