ParisNakitaKejser
ParisNakitaKejser

Reputation: 14839

jQuery - Own plugin - need small help

I created my own jQuery plugin in 1.4 and now I need a small amount of help.

$.etrade = function()
{

}

I need so I can build code like this

$.etrade = function()
{
    this.var = 'setting';

    this.subfunction = function()
    {
    };
}

when I take function from my plugin I need to use it like this:

$.etrade.var = '5';
$.etrade.subfunction();

Somebody know what I mean? and how I can get this problem done? :)

Upvotes: -1

Views: 91

Answers (1)

Matt Ball
Matt Ball

Reputation: 359786

It sounds like you want to assign a plain old object to $.etrade, not a function. Like this:

$.etrade = {
    variable: 'setting',
    otherVariable: 'something else',
    subfunction: function () { /* do stuff here */ },
    anotherSubFunction: function () { /* do other stuff here */ }
}

That said, I'm not sure how this qualifies as a jQuery plugin, since it looks like you're just tacking an ad-hoc property onto jQuery.

Aside: you can't use var as per your example, since it's a keyword in JavaScript.

Upvotes: 3

Related Questions