简体   繁体   中英

ractive.js multiple checkboxes

This is much like the common multiple checkbox question all over the web, except my list of checkboxes is dynamic.

Simplified:

{{#user}}
    <h2>Roles</h2>
    {{#allRoles:roleIndex}}
      <input type='checkbox' name='{{roles}}' value='{{.id}}'> {{.name}}<br>
    {{/}}
{{/}}

I want to iterate over allRoles (in ~/) and get an array of checked boxes in user.roles but since {{#allRoles:roleIndex}} changes the keypath, I cant figure out how to put roles inside user.

Sometimes the obvious is too obvious.

name='{{user.roles}}' is what I needed

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