Friday, February 27, 2009

[jQuery] Trouble with $(this) in custom plugin

Hi all. I've started creating a small plugin for an internal project
at work however I'm having a bit of trouble. This is my code,

(function($){
$.fn.fsGallery = {
next: function() {
var obj = $(this);

if($('ul li.active', obj).next().length){
/* stuff*/

}
}
}
})(jQuery);

My HTML is

<div id="gallery">
<ul>
<li><img ...li>
</ul>
</div>


and the call is

$('#gallery').fsGallery.next();

When the function, next(), is called, obj returns with all the usual
jquery functions but nothing of my #gallery div above. Any ideas?

No comments: