Loading ...
Sorry, an error occurred while loading the content.

YUI menu event callback not executed in firefox

Expand Messages
  • Dawn Endico
    I m developing a menu control for my google map using YUI menus. The code worked great until I moved the code inside a constructor and now clicking on menu
    Message 1 of 5 , Nov 29, 2006
    • 0 Attachment
      I'm developing a menu control for my google map using YUI menus. The code worked great until I moved the code inside a constructor and now clicking on menu items in firefox doesn't work, although it does in safari. Firebug's event inspector doesn't show any click events when I click on a menu item so the menu's custom event seems to be getting fired but for some reason its not executing my callback.

      Does anyone have any suggestions on how to approach debugging this? The fact that it works in Safari but not Firefox should be a clue. It seems like is some kind of scope issue since it started after I wrapped the code in a closure.

      The current app is here
      http://maps.tafoni.net/MapTypeMenuControl/

      A version that works is here
      http://maps.tafoni.net/MapTypeMenuControl/demo/

      Another broken version, which is closer to the working code
      http://maps.tafoni.net/MapTypeMenuControl/demo2/

      --
      http://www.tafoni.net/
    • Todd Kloots
      Dawn - I cannot consistently repro this bug when I run your examples locally. The problem seems like it could be due to the call to stopPropagation on line
      Message 2 of 5 , Nov 30, 2006
      • 0 Attachment
        Dawn -

        I cannot consistently repro this bug when I run your
        examples locally. The problem seems like it could be
        due to the call to "stopPropagation" on line 21 of
        MapTypeMenuControl.js though:

        YAHOO.util.Event.stopPropagation(p_aArguments[0]);

        Do you need this?

        - Todd


        --- Dawn Endico <endico@...> wrote:

        > I'm developing a menu control for my google map
        > using YUI menus. The code
        > worked great until I moved the code inside a
        > constructor and now clicking on
        > menu items in firefox doesn't work, although it does
        > in safari. Firebug's
        > event inspector doesn't show any click events when I
        > click on a menu item so
        > the menu's custom event seems to be getting fired
        > but for some reason its
        > not executing my callback.
        >
        > Does anyone have any suggestions on how to approach
        > debugging this? The fact
        > that it works in Safari but not Firefox should be a
        > clue. It seems like is
        > some kind of scope issue since it started after I
        > wrapped the code in a
        > closure.
        >
        > The current app is here
        > http://maps.tafoni.net/MapTypeMenuControl/
        >
        > A version that works is here
        > http://maps.tafoni.net/MapTypeMenuControl/demo/
        >
        > Another broken version, which is closer to the
        > working code
        > http://maps.tafoni.net/MapTypeMenuControl/demo2/
        >
        > --
        > http://www.tafoni.net/
        >
      • Dawn Endico
        Thanks for looking at it. Removing the stopPropagation call from demo3 didn t help. I m using both Firefox 1.5 and 2 on two different machines and its broken
        Message 3 of 5 , Dec 1, 2006
        • 0 Attachment
          Thanks for looking at it. Removing the stopPropagation call from demo3
          didn't help. I'm using both Firefox 1.5 and 2 on two different
          machines and its broken both places.


          I finally got the app working by listening to mouseUp events instead
          of clicks so there's not much point in looking at this version any
          more. I'd still like to debug the click problem though if possible.
          What do you do to debug something like this? The event inspector
          wasn't very helpful since no click events are showing up when i click
          on the menu. Printing log entries hasn't been much help either. I'd
          like to tell the debugger to break on a click event but I don't think
          that's possible unless I already know which code would get executed
          next.
          http://maps.tafoni.net/MapTypeMenuControl/

          This new version has the menu control loaded outside the map (way over
          in the upper right of the page) to make sure there are no map
          listeners intercepting the clicks. Its also loaded with
          window.console.log statements which make it look like events.js is
          never seeing any click events.
          http://maps.tafoni.net/MapTypeMenuControl/demo3-disappearingclicks/

          The original two versions where it broke are still here

          http://maps.tafoni.net/MapTypeMenuControl/demo/ (works)
          http://maps.tafoni.net/MapTypeMenuControl/demo2/ (broken)

          --
          http://www.tafoni.net/
        • Dawn Endico
          I ve discovered that the difference between a working and broken menu is in the way I create the menu object. If I do it by hand, the menu works, but when the
          Message 4 of 5 , Dec 4, 2006
          • 0 Attachment
            I've discovered that the difference between a working and broken menu
            is in the way I create the menu object. If I do it by hand, the menu
            works, but when the map's addControl function does it then the menu
            breaks.

            Here's another couple of tests with more debugging code.

            http://maps.tafoni.net/MapTypeMenuControl/test/
          • Todd Kloots
            Hi Dawn - I discovered the problem. It appears that Google is stopping propagation of the click event at the containing DIV for your map ( ).
            Message 5 of 5 , Dec 4, 2006
            • 0 Attachment
              MapTypeMenuControl
            Your message has been successfully submitted and would be delivered to recipients shortly.