That does no achive what i want.  I can only declare and instance of the
class inside the $(function()) which does not help me becuase i might want
to declare X amount of the with different names.

I guess maybe jQuery is not what i am looking for, i mean jQuery seems to
have poor OOP support when it is a bit of a pain in the ass to create a
class.


Ganeshji Marwaha wrote:
> 
>>> why do i get error saying that test is not a function of t?
> 
> Because you are approaching it wrong. This is how u can achieve what u
> want
> to
> 
>             $.ajax_request = function(options) {
>                 this.options = {test: "test"};
>             }
>             $.ajax_request.prototype = {
>                 test: function() {
>                     alert(this.options.test)
>                 }
>             }
>             var test = new $.ajax_request();
>             test.test();
> 
> You can see a demo of it here...
> http://gmarwaha.com/test/other/testClassCreation.html
> 
> Although it is possible to do this, doesn't mean that it is the right way
> to
> approach a problem. Mootools excels in giving class structure to
> javascript.
> But jQuery feels class structure is a overkill and that is the reason why
> class a class framework is not give out of the box.
> 
> Also, as John Resig mentioned in a reply to ur post, creating a class and
> this members is such a trivial task which doesn't benefit much from
> framework intervention. Anyways, if all you want to create is class
> structure, there you go, you got the code and link to the demo...
> 
> Have fun... and welcome to the world of jquery, the world that created a
> difference in my life...
> 
> -GTG
> 
> 
> On 8/11/07, Eridius <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> 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.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Creating-plugins-tf4255335s15494.html#a12112018
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to