Calling a method from within a plugin

Calling a method from within a plugin

Hi,

I'm fairly new to jQuery and very new to authoring and modifying exiusting plugins, so im hoping someone here can help me solve my frustrating little problem.

I basically have a small empty jQuery plugin, with a two functions, which I want to call repeatedly from within my plugin using the setInterval function:

jQuery.fn.carousel = function(){      
   $.extend(this, {
      previous: function(){
      },            
         
      next: function(){            
         alert("hi");
      }
      
   });
   setInterval(this.next(), 400);               
};


Once this plugin has been in intialised, the "next" function is sucesfully called once, however further calls to it raises a javascript error: "Invalid argument".

As im fairly new to jQuery im sure I'm doing something completely illegal above, however from a point of logic I can't immediately see why the first call to it suceeds and following calls fail.

Any help on this would be overjoyouslly appreciated!

Musaffar
    • Topic Participants

    • admin