I'm very new to Ember and I've built this sort of thing before a few times before using JS/jQuery but after 2 hours I just can't seem to make any headway the "Ember" way.
I have a set of permissions that I've pulled from my Permission Model:
[
{
id : 1,
permission : "Can Eat Cake",
description : "User is allowed to eat cake."
},
{
id : 2,
permission : "Can Fly",
description : "User is allowed to fly."
},
...
]
And I want to allow the user to check all that apply to a particular role:
// RoleCreate.hbs
{{#each model.permissions}}
{{input type="checkbox" name="rolePerm" checked=permChecked}} {{permission}}<br />
{{/each}}
Up to this point, everything looks/operates as expected, however, this is where I'm stuck... how do I get an array of ids/values for the checked checkboxes so I can create an object like the below to send back to the server to actually create the role?
{
roleName : "My new user role",
permissions : [ 1, 2 ]
}
I just have no idea how to get the values of each checkbox to a parent array that can be sent to the server to create the new role... I've managed to figure out how to get an observer to fire on check/uncheck but can't seem to get the value of the checkbox no matter what I try.
// RoleCreateController
rolePermissionMgr : function() {
console.log( "Permission Checkbox Changed!" );
}.observes( '[email protected]' )
Again, very new to Ember so I'm sure I've done one or more things incorrectly.