I create a simple plugins and bind it to two div in my pages.
..............................................................
jQuery.jUpload = function()
{
        var test;

        return {
                startUpload: function()
                {
                        alert(test);
                },

                setVars: function(_test)
                {
                        test = _test;
                }
        };
}

jQuery.fn.jUpload = function(_test)
{
        this.each(function()
        {
                jQuery.jUpload.setVars(_test);

                var butUpload = jQuery("<button></button>").append('upload');
                butUpload.bind('click', jQuery.jUpload.startUpload);
                jQuery(this).append(butUpload);
        });
        return this;
};

<script>
$(document).ready(function() {
        $('#divOne').jUpload('test one');
        $('#divTwo').jUpload('test two');
});
</script>

<div id="divOne"></div>
<div id="divTwo"></div>
..................................................................................
what I want to know, is how the variable 'test' can be unique(private)
for each plugins .. (like variables in class on php) ... in this case,
the divTwo overwrite the variable test. so when I click the button on
divOne and divTwo, it always display 'test two'.... thanks

Reply via email to