I’m going over the jquery widget here: http://blog.davidpadbury.com/2010/10/11/bdd-testing-of-jquery-plugins-using-jasmine/
The plugin is called like so:
$('#list').list({'input':$('#new-value')})
So ‘#new-value’ is an input text field. By wrapping $() around ‘#new-value’ it is a jQuery selection.
Inside the widget _create method there is this line:
this.input = $( this.options.input )
this.options.input should be $('#new-value'). It’s already a jQuery object right? Why are they wrapping it within another $( )? What does that do? Can I leave it out?
It is probably implemented, so the selector could be given instead of object as the
inputoption.Passing jQuery object into jQuery function changes nothing – the same object is returned. Well, maybe not the same object, but the documentation says about
jQueryfunction:so it will retrieve DOM objects from jQuery object and pass them again to jQuery function, returning the result.