1

I have the following code written in Dojo. It works fine and as expected in all browsers except Firefox (25,26) The error from the console is: typeError: this.getParent() is null which is really not helpfull a lot.

The onclick event does't fire giving the above mentioned error.

Where could the problem be:

  var pMenu = new dijit.Menu({
        targetNodeIds: [ContainerNode]
    });

 var t = new dijit.MenuItem({
        label: "test",
        iconClass: "context_paste",
    });

dojo.connect(t, 'onclick', function(){alert("test")});
4
  • Is ContainerNode an ID or a variable? If it's the former, it should be a string. If it's the latter, what is its value? Commented Nov 14, 2013 at 0:38
  • So far any cases I've heard of DOM-related errors with older Dojo versions on FF 25+ are due to bugs.dojotoolkit.org/ticket/17400, but if I'm not mistaken, a new 1.6 release with the fix hasn't been tagged yet. You might want to try applying it yourself and see if it resolves your issue: github.com/dojo/dojo/commit/… Commented Nov 14, 2013 at 1:52
  • The containerNode is a variable containing a DIV element.
    – Jacob
    Commented Nov 14, 2013 at 9:18
  • @KenFranqueiro I tried to use latest code from 1.6 branch in git that has this change applied but unfortunately it does not solve the problem.
    – matejk
    Commented Dec 2, 2014 at 7:49

1 Answer 1

1
+100

I created a fiddle and filled in the missing code and was not able to reproduce the error on Firefox 25. Some of the changes that I made were:

  • Removed the trailing comma at the end of the iconClass line
  • Place the menu item in the menu with placeAt(pMenu)
  • Ran the code on load. I'm not sure you were doing this from the code provided.

http://jsfiddle.net/RichAyotte/okvp0hpu/

dojo.require('dijit.Menu');
dojo.require('dijit.MenuItem');

dojo.addOnLoad(function() {
    var ContainerNode = document.getElementById('container');

    var pMenu = new dijit.Menu({
       targetNodeIds: [ContainerNode]
    });

    var t = new dijit.MenuItem({
        label: "test",
        iconClass: "context_paste"
    }).placeAt(pMenu);

    dojo.connect(t, 'onClick', function(){alert("test")});
});

Not the answer you're looking for? Browse other questions tagged or ask your own question.