I created an object in a plugin above .fn
. For they are usually created within the objects of which we do the following:
(function( $ ){
$.fn.tooltip = function(options) {
var defaults = {
'corDeFundo' : 'yellow'
};
var settings = $.extend( {}, defaults, options );
return this.each(function() {
$(this).css({ background: settings.corDeFundo });
});
};
})( jQuery );
But my object was created above:
(function( $ ){
var m = {
"input" : "outado",
init:function(options){
console.log(m.seletor);
return m.seletor;
},//INIT FIM
}
$.fn.input= function(method) {
var settings = $.extend( {}, defaults, method);
console.log(m.seletor);
return m.init.apply( this, arguments );
};
})( jQuery );
$("div").input({
input : "red"
})
How do I define the attributes of the object, since to get it I do so inside the function: m.seletor
. But how do I change what I have to do?
Correction: Just use it as follows:
var settings = $.extend( {}, m, method );
console.log(settings.seletor)
My problem really is : How do I pass this changed object to the INIT()
function? Will I have to create another object, or what?