Storing a jQuery plugin so it can be used in a different function

12 Views Asked by At

A jQuery plugin instance is created inside a certain function. What is the recommened way to store it so the the returned plugin can be used inside another function?

code:

(function($){
    $.fn.myplugin = function(){
        ...
        return this;
    };
}(jQuery));


function f(){
  var pluginInstance = $('#selector').myplugin ();
  ...
}

function g(){
 //I want to use pluginInstance here.
}
0

There are 0 best solutions below