Assigning permissions to different user roles

Hello to all…!!

I’m working on a dummy project where I need to assign different types of task to different user roles… which I’m making this through synced checkbox inputs from Mongo…

Here is the html code for input…

    <tbody>
          {{#each TasksList}}
              <tr>
                <td> 
                {{TaskName}}
                </td>
                {{#each RolesList}}
                  <td >  
                    <input type="checkbox" checked="{{checked}}" class="p-{{_id}}_{{../_id}}"  value="{{../_id}}" />
                  </td> 
                 {{/each}}
              </tr>
          {{/each}}
      </tbody>

where, TasksList is the collection created on Mongo, and RolesList is another collection created.
And class p-{{id}}{{…/_id}} is p-roleId_taskId fetching from the above collections.

On the click event of input, all the checked taskIds are stored in the form of array field tasks in RolesList collection… But whenever I’m fetching from Mongo through {{checked}} helper there is showing all checkbox checked on manually refreshing on the current role assigning template page… but on automatic refresh of the rendered template page it is showing checked the selected on the click event

Here is the code for helper {{checked}} on client side…

 Template.assignRoleForm.helpers({
    checked: function() {
      var tasks = TasksList.find({}).fetch();
      var roles = RolesList.find({}).fetch();
      var checked = false;

      for(var i=0; i<roles.length; i++) {
        for(var j=0; j<tasks.length; j++) {
          var task = tasks[j]._id;
          var taskArray = roles[i].Tasks;
          var role = roles[i]._id;
          if(taskArray.indexOf(task) !== -1) {
            checked = $(".p-"+role+ "_"+task).attr('checked', true);
          } else {
            checked = $(".p-"+role+ "_" +task).attr('checked', false);
          }
        }
      }; 
      return 1;
    }
   });

Plzzz anyone tell me what I’m missing…

only had a quick look. Arent you always returning “1” from your helper? You might want to return checked?

had already try…
this gives no changes to me…
if I return either 1(true), 0(false) or checked.