views:

22

answers:

2

Let's say I've created this plugin:


$.fn.my_namespace = function() {}

with level 1 sub functions:

$.fn.my_namespace.category_func = function() {}

and level 2 sub functions (actual application):

$.fn.my_namespace.category_func.app_func() {
   alert(this);
   alert(this.selector);
}

Execution:

$('div').my_namespace.category_func.app_func();

how can I now in my app_func retrieve the actual selector? In this case, 'this' seems to be the parent function (category_func) and not the jQuery object (selector).

How come? And how do I access the selector from app_func() ?

A: 

jQuerys .fn namespace is intended to hold functions which return a jQuery object / array of objects.

You can't just throw a new object in there and expect everything to work just like that.

jAndy