$(document).ready() { should be $(document).ready(function(){
On Nov 17, 8:06 am, echobase <bushbr...@gmail.com> wrote: > Hi- > > I'm just getting into jQuery plugins and I wanted to do a sort of > 'hello world' exercise with a barebones plugin template. My template > code is below but I can't get the console.log statement in the setup() > function to show in a firebug console window. IIf I put a console.log > statement immediately following the top line: > > ;(function($) { > console.log('hello world'); > > .....it does work. Can someone please tell me what I'm doing wrong? > > I call the plugin like so: > > <script type="text/javascript" src="myPlugin.js" > > <script type="text/javascript"> > $(document).ready() { > $('ul').myPlugin(); > }); > </script> > > myPlugin.js: > > ;(function($) { > > $.fn.extend({ > myPlugin: function(options) { > return this.each(function() { > new $.MyPlugin(this, options); > }); > } > }); > > $.MyPlugin = function(element, options) { > var defaults = { > helloText: "hello World" > } > > this.options = $.extend({}, defaults, options || {}); > > this.setup(); > }; > > $.extend($.MyPlugin.prototype, { > > setup: function() { > console.log(this.helloText); > } > }); > > })(jQuery);