iron-meteor/iron-router

Events in yielded regions

Opened this issue · 0 comments

So, I have a couple of regions in my default layout that look like this:

  <div class="title_left">
    <h3>{{> yield "pageTitle"}}</h3>
  </div>

  <div class="title_right">
    {{> yield "pageOptions"}}
  </div>

In the page pageOptions region, I'm passing a block that contains two buttons:

<template name="myView">
  {{#contentFor region="pageOptions" incident=incident that=this}}
    <div class="col-md-7 col-sm-7 col-xs-12 pull-right text-right">
      <button data-action="open" class="btn btn-sm btn-default setAction">
        Set as open
      </button>

      <button data-action="closed" class="btn btn-sm btn-default setAction">
        Set as closed
      </button>

      <a href="#" class="btn btn-default btn-sm">Back</a>
    </div>
  {{/contentFor}}
</template>

Both buttons have an onClick event associated:

Template.myView.events
  'click .statusSelect': (evnt, tmpl) ->
    action = evnt.target.getAttribute 'data-action'
    {_id} = tmpl.data
    selector = _id or null
    MyCollection.update _id, $set: {action}

However, when these buttons are inside the {{contentFor}} block, the event listeners are deafs. I may be wrong on this, but maybe the template context changes when from one block to the other.

So, my question is, how can I keep the context of the myTemplate template inside the pageOptions region? Or, if it is possible, how can I pass the event listeners to region?

Here are the packages I'm using:

  • iron:controller@1.0.8
  • iron:core@1.0.8
  • iron:dynamic-template@1.0.8
  • iron:layout@1.0.8
  • iron:location@1.0.9
  • iron:middleware-stack@1.0.9
  • iron:router@1.0.9
  • iron:url@1.0.9
  • blaze@2.1.3
  • blaze-html-templates@1.0.1
  • blaze-tools@1.0.4
  • meteor@1.1.10
  • meteor-base@1.0.1