Take the 2-minute tour ×

I'm making my first Jquery Plugin and overcome many problems after I found one that I can not find solution.

The plugin convert a table in a tree-gridview doing a $(element).treeGD(); sentence, that part works ok. But i want to reload all data doing $(element).treeGD.reload();

The first sentence creates an object objTreeGD(obj):

$.fn.treeGD = function () {

    var treeGD = new objTreeGD(this);

And adding the second method in the way i'll show you now and trying to use the same treeGD object created above gives me an error (undefined)

$.fn.treeGD.reload = function () {

    var urlDatos = treeGD.attr("data-url");

Is there a way to access to that firs object i've created?


share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

May be you can use .data() method?

$.fn.treeGD = function () {

    var treeGD = new objTreeGD(this);
    this.data("myTree", treeGD );

And then, access using:

$.fn.treeGD.reload = function () {

    var urlDatos = this.data("myTree").attr("data-url");
share|improve this answer
Please note that I have edited the first answer. There was an error. –  Hariprasad May 20 '13 at 11:57
add comment

Your Answer


