Storing instanced variables in jQuery plugin
<p>I wrote a plugin to validate forms across the network where i work. The problem here is that some of our pages have multiple forms and the global variables get overwritten. I'll try to give an example as best i can. The code itself would be too long to paste.</p>

<p>I know this code is horribly wrong but i'm trying to gauge the best way to achieve using multiple instances of this code without making things too complicated.</p>

<p>jquery plugin:</p>

<pre><code>(function($){

    methods = { 
        'method1': function(){
            alert('form: ' + globals.form_name ); 
        }
    }

    $.fn.validationplugin = function() {
        globals.form_id = $(this).attr('id');
    }(jQuery);

    var globals = {}


}(jQuery);
</code></pre>

<p>html calls:</p>

<pre><code>&lt;form id="form1"&gt;&lt;/form&gt;
&lt;form id="form2"&gt;&lt;/form&gt;

&lt;script type="text/javascript"&gt;
    $('#form1').validationplugin();
    $('#form2').validationplugin();
&lt;/script&gt;
</code></pre>
