Template event is not trigger when in popover

I have this code. The problem is button viewcart click is not executed when click. Button viewcart is inside a popover. Any ideas how to trigger the event of button click viewcart?

header.jade

template(name="header")
  ul.nav.navbar-nav.navbar-right
    li
	button.btn.btn-info.cart(name="cart", type="button", data-container="body", data-toggle="popover", data-placement="buttom") Cart 
	#popover-content.hide
	    +cart

header.coffee

Template.header.rendered = ->
  $('.cart').popover
    placement : 'bottom'
    html: true
    title: 'cart'
    content: ->
      $('#popover-content').html()
    return

cart.jade

template(name="cart") 
    table
        tr
	   td
	       button.viewcart  View Cart

cart.coffee

Template['cart'].events
  "click .viewcart": ->
      console.log 'im click!' 
      return

You’re are creating a new element with this $('#popover-content').html(), it wont be attached to blaze (don’t know if this is the right way to put it). I faced the same issue with popovers on google maps. Where is the popover placed in the DOM?

EDIT: One thing you can do is instead of creating the template that way, just render it somewhere and make it appear whenever you need. You can see how they do it here https://github.com/yogiben/meteor-autoform-modals/ .

@gabrielpoca Your right. Hopefully there will be a facility that allow blaze to re read the page. :smile:. If you have time you can put your answer in my post in stackoverflow . I can give the points to you :smile:

:+1: thank you, I hope the package helps.

1 Like