I am using the following pattern to write a javascript library, but it couldn't receive parameters passed into the functions, am I missing something here?
(function($){
var Foo = function(elements, options){
... ...
}
Foo.prototype = {
constructor: Foo,
bar: function(arg){
console.log(arg); // print 'undefined' here
},
}
$.fn.foo = function(option){
return this.each(function(){
... ...
})
}
$.fn.foo.Constructor = Bricker
$.fn.foo.defaults = {
... ...
}
})(jQuery)
When I call $('select').foo('bar', content), content will be logged as 'undefined', can anyone tell me the problems?