Jacob
Jacob

Reputation: 4031

Strange firefox error with Dojo 1.6.2

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")});

Upvotes: 1

Views: 218

Answers (1)

Richard Ayotte
Richard Ayotte

Reputation: 5080

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")});
});

Upvotes: 1

Related Questions