views:

194

answers:

1

Why am I getting too much recursion on a jQuery plugin this.each iteration?

(function($) {
  $.fn.selectableList = function(options) {
    return this.each(function() {
      var $this = $(this);
      $this.elem = $this.children('li').click(onClick);
    });
    function onClick() {
      //do something
    }
  }
})(jQuery);
+2  A: 

try just $(this).find('li').click(onClick); instead of the 2 lines you have there, that should not produce too much recursion

meosoft
@meosoft Thanks!! that solved my problem.
Sam3k