javascript - Controlling the return for a freshly created jquery widget -


i have created jquery plugin simple , not stateful, since plan on making stateful later, used jquery widget. now, _create function has code in it. i've found out through experimentation when widget called, jquery object returned unchanged previous object in chain.

$('.myclass').myplugin().someothermethod(); 

at end of .myplugin(), still $('.myclass') selected.

well, plugins, fine. however, in particular plugin, i'm wrapping selected element new tag , i'd return wrapper instead. i'd return this.element.parent().

trying write return statement in _create function not seem work , in examples i've seen, _create never have return statement. how solve this?


Comments