On 1/13/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

Jonathan Sharp schrieb:
> I finally got around to finishing the pages and packaging the plugin
> last night. Enjoy!
>
> http://jdsharp.us/code/jQuery/plugins/jdMenu/
Great to see an update to this plugin!

Have you considered or tried an event delegation approach? That is,
assign the click handlers to the entire menu instead of each li, and use
the event's target property then. You'd have less event handlers, though
more code to figure what to do when the event is fired. And you can add
and remove as many elements as you like, there would be no need to un-
or rebind any event handlers.


I'd be very interested in this approach. Is jQuery's even object that gets
passed in "standard" or would I have to code around W3C/IE target vs.
srcElement? I would assume that I'd just need to attach a top level event to
my root UL. I'll see what I can refactor. I'm testing 1.1 with our
application today and so far hasn't been any major changes.

For 1.1 compability, I think the only thing you have to change is
ancestors() to parents().


I've made these changes locally, works great with 1.1.

Maybe we should move ancestorsUntil (or rather, parentsUntil) and
next/prevUntil to it's own plugin. You could then provide both
jdMenu-only package and a jdMenu-with-dependencies package.

The bgiframe plugin is really easy to use, you just apply it to all
elements that need the iframe.


I'm looking at implementing this now.

Of course it would be nice to customize the behaviour via options, but
that was also mentioned before.

And a hint that works from 1.1 on:
The intialization code at the top depends on the $ alias. You can avoid
that even without the custom alias pattern used for the plugin itself.
As of 1.1, a reference to the jQuery function is passed as an argument
to the document ready event. So you can rewrite this:

$(function(){
       $('ul.jd_menu').jdMenu();
       $(document).bind('click', function() {
               $('ul.jd_menu ul:visible').jdMenuHide();
       });
});

To this:

jQuery(function($){
       $('ul.jd_menu').jdMenu();
       $(document).bind('click', function() {
               $('ul.jd_menu ul:visible').jdMenuHide();
       });
});

And none of the code would depend any more on the $ alias being present.


Also made this change locally.

Cheers,
-js
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to