Results 1 to 3 of 3

Thread: Flex Level Popup Menu - can I make it onclick instead of onmouseover?

  1. #1
    Join Date
    Jan 2010
    Location
    Conroe, TX
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Flex Level Popup Menu - can I make it onclick instead of onmouseover?

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    	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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •