PDA

View Full Version : Flex Level Popup Menu - can I make it onclick instead of onmouseover?



JasonS
01-05-2010, 10:10 PM
1) Script Title: Flex Level Popup Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/popupmenu.htm

3) Describe problem: I am using this script with an image map, but would like the menu to come up when clicking on the area instead of just popping up. Is there a way to do this?

Thanks,
Jason

jscheuer1
01-06-2010, 08:46 AM
Well you know, if the area is a link, it can no longer function as one, except of course for non-javascript enabled users. That can actually be a good thing. It's something to be aware of though.

That said, to answer the question, edit the popupmenu.js file, replacing its init function with this one:


init:function($, $target, $popupmenu){
if (this.builtpopupmenuids.length==0){ //only bind click event to document once
$(document).bind("click", function(e){
if (e.button==0){ //hide all popup menus (and their sub ULs) when left mouse button is clicked
$('.jqpopupmenu').find('ul').andSelf().hide()
}
})
}
if (jQuery.inArray($popupmenu.get(0).id, this.builtpopupmenuids)==-1) //if this popup menu hasn't been built yet
this.buildpopupmenu($, $popupmenu, $target)
if ($target.parents().filter('ul.jqpopupmenu').length>0) //if $target matches an element within the popup menu markup, don't bind onpopupmenu to that element
return
$target.bind("click", function(e){
$popupmenu.css('zIndex', ++jquerypopupmenu.startzindex)
jquerypopupmenu.positionul($, $popupmenu, e)
jquerypopupmenu.showbox($, $popupmenu, e)
e.preventDefault();
})
$target.bind("mouseenter", function(e){
clearTimeout($popupmenu.data('timers').hidetimer)
})
$target.bind("mouseleave", function(e){
jquerypopupmenu.hidebox($, $popupmenu)
})
}
}

That's it.

bellalamb
02-28-2010, 12:56 PM
Hi

Is there a way to make the popupmenu work on click OR or mouseover ?

I find some users trying to click rather than waiting for the mouseover to take effect

Regards

Paul