[jQuery] Re: Making An Intergrated Plugin

2007-08-14 Thread Bernd Matzner
> Inside the plugin method "this" is already a jQuery object, thus you > And you usually shouldn't forget to maintain chainability by returning > the object: Thanks for reminding, I keep forgetting about these basic jQuery principles - after all, that's what jQuery is about... Grüße in die Sred

[jQuery] Re: Making An Intergrated Plugin

2007-08-14 Thread Klaus Hartl
Bernd Matzner wrote: Hi Eridius, yes, "this" refers to the object passed to the plugin, in your case $('#hover_menu').hover_menu(); which would be shorter than $('div[id=hover_menu]').hover_menu() (function($) { $.fn.hover_menu = function(){ $(this).children('ul').children('li')

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Joel Birch
On 8/14/07, Karl Swedberg <[EMAIL PROTECTED]> wrote: > > > On Aug 13, 2007, at 7:35 PM, Joel Birch wrote: > > Also, to get all the li elements within the initial object, I used find() > instead of children(). I'm a bit foggy on what the difference is at the > moment, but find works me. > > The diff

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Karl Swedberg
On Aug 13, 2007, at 7:35 PM, Joel Birch wrote: Personally, I'd use: jQuery.fn.hover_menu = function(offset, speed){ this.find('').each(function(){ // 'this' is already a jQuery object (the one you attach the plugin to) var current_margin = $(this).css('marginLeft'); // 'this' ne

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Joel Birch
On 8/14/07, Joel Birch <[EMAIL PROTECTED]> wrote: > > jQuery.fn.hover_menu = function(offset, speed){ >this.find('').each(function(){ // 'this' is already a jQuery object > (the one you attach the plugin to) >var current_margin = $(this).css('marginLeft'); // 'this' needs to > be wrap

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Joel Birch
Personally, I'd use: jQuery.fn.hover_menu = function(offset, speed){ this.find('').each(function(){ // 'this' is already a jQuery object (the one you attach the plugin to) var current_margin = $(this).css('marginLeft'); // 'this' needs to be wrapped in a new jQuery object }); Note w

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Eridius
Ok. I think i will use that way because too me it looks a lot cleaner. bmsterling wrote: > > Eridius, > Your plugin code will work, but the preferred method is the method that > Bernd wrote. > > On 8/13/07, Eridius <[EMAIL PROTECTED]> wrote: >> >> >> >> everything you said there makes sense

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Benjamin Sterling
Eridius, Your plugin code will work, but the preferred method is the method that Bernd wrote. On 8/13/07, Eridius <[EMAIL PROTECTED]> wrote: > > > > everything you said there makes sense but the plugin code, i thought i > made > the plugin like this: > > jQuery.fn.hover_menu = function(offset, spe

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread seedy
I think what you are looking for is .children() $('div[id=hover_menu]').hover_menu( $(this).children('li') ) Eridius wrote: > > I am trying to learn the working of making a intergrated plugin(with using > jQuery.fn.plugin method). I thought a good start would be a simple > hover_menu. Now m

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Eridius
everything you said there makes sense but the plugin code, i thought i made the plugin like this: jQuery.fn.hover_menu = function(offset, speed) { var self = this; ${self).children('').each(fucntion() { //grab current margin var current_margin = this.css('marginLeft')

[jQuery] Re: Making An Intergrated Plugin

2007-08-13 Thread Bernd Matzner
Hi Eridius, yes, "this" refers to the object passed to the plugin, in your case $('#hover_menu').hover_menu(); which would be shorter than $('div[id=hover_menu]').hover_menu() (function($) { $.fn.hover_menu = function(){ $(this).children('ul').children('li').hide(); }; })( jQu