Hi,
I am trying to implement a context menu in Meteor App. so far I have following. I am rendering the context_menu
template using Blaze.renderWithData(Template.context_menu, data, containerEl)
.
Template.context_menu.onCreated ->
$('.context_menu').remove() ## Remove any existing contextmenu on page
Template.context_menu.onRendered ->
cMenuSelector = '.context_menu'
@$(cMenuSelector).css
left: @data.x or 'initial',
top: @data.y or 'initial'
display: 'block'
$(document).on 'click.contextmenu, contextmenu.contextmenu', (e) ->
$(cMenuSelector).css({display: 'none'})
$(document).off 'click.contextmenu, contextmenu.contextmenu'
Template.context_menu.onDestroyed ->
console.log "destoyed", @
Jade template file as below.
template(name="context_menu")
ul(class="context_menu")
each menuitems
li(class="ctxmenuitem")
a(tabindex="-1" data-action="{{action}}" data-value="{{data}}") {{label}}
Menu items are passed dynamically and i m binding click event to the a
and taking action appropriately using data-action
attrib.
When I right click multiple times it does display menu and old context menu dom is removed. However, template destoryed
event doesnt fire.
Any help much appreciated about this approach and will removeing the dom, remove the temlate instance or not?
Thanks…