Assign JQuery Selector to a Variable Once
<p>I have a JQuery plugin function where I would like to assign selectors from an iframe just once, and then use them throughout the plugin.  </p>

<p>In the basic example below, if I have a function within the plugin it won't work for the $modal selector unless I explicitly set it within the function.  </p>

<p>Is there any way to do this so that I can assign the selector to a variable just once and have it accessible throughout the plugin function?</p>

<pre><code>jQuery.customPlugin = function() {


    var $modal = $('#modal', frames['admin-bar'].document);


    $('#hide-modal').click(function(){

        hide_modal();

    });

    // doesn't work - but I want it to somehow
    function hide_modal(){

        $modal.hide();

    }

    // works, but requires lots of re-querying if I have lots of selectors/functions
    function hide_modal(){

        var $modal = $('#modal', frames['admin-bar'].document);
        $modal.hide();
    }

});
</code></pre>
