The problem with understanding the JavaScript syntax of the selected plugin, consultation is needed
I want to be a javascript programmer, so I am trying to read and understand the code in the plugin of my choice .
I know how to create a jquery plugin and I read about the module pattern, but this code is not clear to me:
//...
attaching to jQuery object
//...
$.fn.extend({
chosen: function(options) {
return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) {
return new Chosen(this, options);
}
});
}
});
//...
//...
//...
Chosen = (function() {
__extends(Chosen, AbstractChosen);
function Chosen() {
Chosen.__super__.constructor.apply(this, arguments);
}
// ...
// attaching various events
// ...
return Chosen;
})();
If Chosen is a function called by itself - why use it with the new statement ? thank
+3
source to share