I am having a bit of trouble creating an instance of useful things from another JS file, I would like to change the properties of the instance and use the methods. Or whatever you suggest if this is not possible. This extends and this construct are confusing me.
(function($) {
$.extend({
usefulThings: new function() {
this.defaults = {
prop_path:'/la/lala',
//OTHER STUFF
};
this.construct = function(options) {
return this.each(function() {
var setting;
this.settings = {};
settings = $.extend(this.settings, $.usefulThings.defaults, options);
$this = $(this);
//OTHER STUFF
$.data(this, "usefulThings",settings);
// FIRST METHOD CALL
//OTHER STUFF
});
};
//SOME METHODS
}
});
$.fn.extend({
usefulThings: $.usefulThings.construct
});
})(jQuery);
I have seen usefulThings called from script blocks like so:
$("#myDivName").usefulThings({
prop_path: '/la/lala' //these seems to get overwritten in the above
});