5
I created an object in a plugin above .fn
. Because usually they are created inside the objects from there 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, because to catch I do so within the function: m.seletor
. But to change how I have to do?
Correction: Just use it like this:
var settings = $.extend( {}, m, method );
console.log(settings.seletor)
My real problem is: How do I pass this object changed to the function INIT()
? I’ll have to create another object, or what?
Hello. Where is "m.selector" not supposed to be "m.input"? If I understand correctly what you want is for the.log console to give the result of "red". That’s it?
– Tiago Gomes