Use $(selector).data() functionality for automatic variables.

Or move variable declaration up to function($), if this data are
static.

On 20 фев, 10:21, Tim <tcw...@gmail.com> wrote:
> How do I access options that have already been initialized from a
> public method?
> example:
>
> jquery.plugin.js:
> (function($j) {
> $j.fn.plugin = function(options) {
>
>         // build main options before element iteration
>         var opts = $j.extend({}, $j.fn.overviewSummary.defaults,
> options);
>         alert(opts.test);
>
> };
>
>     $j.fn.plugin.publicFunction = function(options) {
>         //how do i read the previously initialized options without
> having to pass them twice?
>         alert(opts.test);
>      };
>
> .....................
>
> // from another file i call the plugin like this:
> $j("#divTarget").plugin({
>     test: 'It works!'
>
> }; // output 'It works!'
>
> $j("#divTarget").publicFunction(); // undefined
>
> -------------------------
>
> does anyone know how to read in the jquery options that were
> initialized via the options parameter from the initial plugin call?
> subsequent public method calls to that plugin return undefined (see
> the comments in the pseudocode)
>
> Thanks in advance,
> Tim

Reply via email to