Ⓙⓐⓚⓔ schrieb:
> I think we're on the right track but now I get a firefox exception.
>
> http://cigar.dynalias.org/js/rolly.js
>   
Try this:

$.fn.rolly = function(options) {
        var settings = $.extend({
                speed: 'fast',
                delay: 10000
        }, options || {});
        $(this).children().eq(0).animate({ width: 'hide', opacity: 'hide' }, 
settings.speed).appendTo(this).show(settings.delay);
};

You don't have to use $.blabla = function() ... if your plugin is simple 
enough. Define simple helper functions within your plugin function, that 
should suffice in this case. But if you delegate to other function, you 
must pass "this", too. Something like this:

$.fn.rolly = function(options) {
        var settings = $.extend({
                speed: 'fast',
                delay: 10000
        }, options || {});
        var helper = function(jq) {
                jq.children().eq(0).animate({ width: 'hide', opacity: 'hide' }, 
settings.speed).appendTo(this).show(settings.delay);
        };
        helper(this);
};

Or you save "this" into a variable and use it within the function:


$.fn.rolly = function(options) {
        var settings = $.extend({
                speed: 'fast',
                delay: 10000
        }, options || {});
        var jq = this;
        var helper = function() {
                jq.children().eq(0).animate({ width: 'hide', opacity: 'hide' }, 
settings.speed).appendTo(this).show(settings.delay);
        };
        helper();
        setTimeout(helper, settings.delay);
};

Hope that helps.

-- Jörn



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to