ok here is my code:
jQuery.ajax_request = function(options) { ajax_options = { test: 'test' }; test = function() { alert(this.test); } } var test = $.ajax_request(); test.test(); why do i get error saying that test is not a function of t? Ganeshji Marwaha wrote: > > When you create a plugin that will be executed on a selected set of DOM > elements, you use > > jQuery.fn.myPlugin = function() {} > > When you create a plugin that is going to be executed statically, like > $.ajax, you create it like this. > > jQuery.myPlugin = function() {} > > Effectively, jQuery is an instance of a class and jQuery.fn is nothing but > jQuery.prototype. > So. if you assign functions to jquery.fn, then you are creating plugins > that > operate on instances of jquery (eg: when a set of dom elements are > selected > using the $() syntax). > If you assign functions to jQuery itself, it can be executed statically on > a > jQuery object itself. Like $.ajax. > > Hope that helps > > -GTG > > > > > On 8/11/07, Eridius <[EMAIL PROTECTED]> wrote: >> >> >> >> I don't know what happen with the last post but let me try to explain >> myself >> better in this one. >> >> The only way i see documenetation for building plugins is so you can add >> like: >> >> $('#whatever').plugin(); >> >> Now this is all good but I want to know something different. I want to >> be >> able to build a plug so i can do something like the $.ajax, so something >> like: >> >> var whatever = new someplugin(); >> >> This way of creating a new class is one thing i love about mootools, in >> mootools i can do: >> >> var ajax_request = new Class( >> { >> //class code >> }); >> >> var ajax_request_handle = new ajax_request(); >> >> Is this possible n jQuery? >> -- >> View this message in context: >> http://www.nabble.com/Creating-plugins-tf4254598s15494.html#a12108667 >> Sent from the JQuery mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://www.nabble.com/Creating-plugins-tf4255335s15494.html#a12111289 Sent from the JQuery mailing list archive at Nabble.com.