Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Helper methods on route change

$
0
0
You should take advantage of live-binding, so it will automatically update to reflect changes in your app state. This means passing in arguments to the helper, and/or calling attr(). Putting your code in a jsfiddle could get you better help, but the gist of it is:

Your template:
  1. <div id="{{guid}}" class="panel-body {{#isCurrent guid}}active{{/isCurrent}}">
Your helper:
  1. ifCurrent: function(guid, options) {
  2.       guid = can.Mustache.resolve(guid);
  3.       if (can.route.attr('placeTypeGuid') == guid) {
  4.             return options.fn();
  5.       } else {
  6.             return options.inverse()
  7.       }
  8. }


Viewing all articles
Browse latest Browse all 3491

Trending Articles