javascript - Pass in parameter to handlebars helper -


so have handlebars helper simple -

handlebars.registerhelper('selectrow', (rowindex, selectedids) ->   console.log 'row index'   console.log rowindex   console.log selectedids   isselected = _.indexof(rowindex, selectedids)   if isselected > -1      return 'class="row-selected"' ) 

and have handlebars code -

<div class="title">{{ title }}</div> <hr/> <table cellspacing="0" cellpadding="0">   <thead>     {{#each columns}}     <th class="col-heading" data-heading="{{ }}">{{ }}</th>     {{/each}}   </thead>   <tbody>     {{#each rows}}         <tr {{#selectrow @index selected }}>           {{#each this}}           <td>             {{this}}           </td>           {{/each}}         </tr>       {{/selectrow}}     {{/each}}    </tbody> </table> 

the selected parameter undefined. if add {{ selected }} anywhere else, shows array, which, can see below, should -

data = @model.data() selected = @model.get('selection').get('selected') @$el.html(@tablecontentstemplate({   columns: @model.get('columns')   rows: data   title : @model.get('title')   selected: json.stringify(selected) })) 

how pass in selected parameter correctly helper?

you're using selected variable inside handlebars each loop, imagine selected not in scope.


Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -