Context menu not passing proper object #745

mikefromcanada opened this Issue Mar 9, 2013 · 2 comments

2 participants


I'm using a dynamically created imagelist with some custom attributes on each item that I need access to.
But the object that's passed from the context menu doesn't seem to be the actual object from the image list.

Some code to explain:
<div id="mycontextmenu" data-bb-type="action" data-bb-img="images/actionBar/cog_dark_theme.png" onclick="alert(">Delete</div>
Will produce the expected results (displays the innerhtml of my list item)
<div id="mycontextmenu" data-bb-type="action" data-bb-img="images/actionBar/cog_dark_theme.png" onclick="myfunction(">Delete</div>

function myfunction(item){

Errors out, saying that the object doesn't support getAttribute.
The exact error message in the console log is: "Object # has no method 'getAttribute'"

The simplest way to see this problem would be to take the contextmenu sample and change the onclick line for one of the context menu items. I'm just trying to pull the data-bb-img value as an example. This does not work.


Open Source Projects member

In you example you are passing in which is text. That is why there isn't a getAttribute in your "myFunction". You would need to pass in to get the DOM element selected.


Sorry, I messed up the code snipits in the OP. The one where I'm passing is actually just
I'll upload a sample in a minute.

Edit: well now I feel foolish, it's not a bug, just a mistake on my part. In the example above, I was assigning the 'id' attribute to the button in the context menu rather than the context menu container itself.

For anyone who has the same problem, here is the proper markup:

<div id="foo" data-bb-type="context-menu">
      <div data-bb-type="action" data-bb-img="images/cog.png" onclick="alert('Your Item is ' + document.getElementById('foo').menu.selected.selected.getAttribute('id'));">Delete</div>
@tneil tneil closed this Mar 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment