Transferring data to Ember JS from Handlebars

I have a menu bar whose status / color changes when clicked. They apply to different JSP / HTML pages. When I click on the page, the #bindAttr pen appears, which solves the class of each tabbed menu item. For example,

<li id="index" {{#bindAttr class="active"}}> <a href="./index.jsp"> <i class="icon-dashboard"></i> <span>Dashboard</span> </a> </li> 

What I need here is to pass something else so that the computed property can find, based on location.href, whether this class should be true. Is there a way to pass the tag identifier "li" to the computed property "active"

+1
source share
1 answer

I decided. Custom Function HandleBar Helper

 <li {{activetab "index.jsp"}}> Handlebars.registerHelper("activetab", function(tabname) { var currentPage = window.location.href; console.log(currentPage); if(currentPage.indexOf(tabname)!=-1){ return "class=active"; } else{ return ""; } }); 
0
source share

All Articles