简体   繁体   中英

ember.js handlebar - using variables inside action helper

I am trying to create dynamic menu for a cms. I have action and target variables stored in database and I want to pass those to action helper:

<li><a href="#" {{action this.action target=this.controllername}}>{{unbound this.name}}</a></li>

I wrote the above code and I am getting the following error on console:

target[actionName] is undefined

return target[actionName].call(target, event);

Kindly let me know what is the right way to do this.

Regards, Karthik

I think in this jsfiddle you find the answer to your question:

http://jsfiddle.net/Malkyne/ydTWZ/

{{#each item in content}}
    <li>
        <a {{action select item}} {{bindAttr class = "item.classNames"}}> 
            {{item.label}}
        </a>
    </li>
{{/each}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM