Hi - am new to javascript and web stuff. Am using Superfish for some menus - think it's great and has saved a lot of time however there is one feature that has been bugging me.
For many of my selectable/clickable menu items I'm using ajax to add content to the page. When a menu item is clicked the menu remains visible until the mouse is moved off the element (on a blur event) plus any 'delay' that has been configured in. To my mind once a menu item has been 'clicked' - the choice has been made and I want the sub-menu to disappear straight away. If the option is not selected then the way it currently operates is fine. So to achieve this I have added a new 'method' to fn.superfish - changes below. It seems to have the desired affect but as I'm a newbie and do not fully understand the original code I am not sure if this is a good way to go about it or not. If true OOP I'ld have created a subclass and added the method there thus leaving the 'base' class alone - perhaps there is a way to 'extend' superfish without modifying the original code? ;(function($){ $.fn.superfish = function(op){ ................ }, // 'method' to hide a submenu once it has been clicked clicked = function(){ var $$ = $(this), numKids = $(this).children().length; rem = numKids % 2; // only hide if menu item has no sub-menus if ( numKids > 1 && rem == 1 ) { $$.hideSuperfishUl(); } }, // end of clicked 'method' out = function(){ ............... $a.each(function(i){ var $li = $a.eq(i).parents('li'); $a.eq(i).click(function(){clicked.call($li);}).focus(function() {over.call($li);}).blur(function(){out.call($li);}); }); .................