I want to pass the currently called object with it's currently set parameters on to a closure function. I'm not sure how to do this in general, but then I think jQuery adds another layer of confusion because this refers to an element.
Example:
jQuery Plugin
(function( $ ){
$.fn.addContentType = function(obj) {
var name = "this is just an example";
obj.func.call(this); //<--I want to pass this object, not the jQuery selector
};
})( jQuery );
Call to Plugin
jQuery("#someelement").addContentType({
func:function(){
console.log(this.name); //<--Expect "this is just an example"
}
});
Any ideas how to do this?
This is just an example and doesn't do anything, I'm just trying to show what I'm after. If I am missing details, let me know.