Strange behavior for all inputs


#1

Let me show a code before I will explain a trouble:

my view helpers

Template.test.helpers({
    checkboxes: function() {
        // some reactive var I need it for regenerate list of checkboxes in some test cases
        var mode = Session.get('mode');

        return [
            {
                active: false,
                description: "Custom 1",
                name: "custom1"
            },
            {
                active: false
                description: "Custom 2",
                name: "custom2"
            },
            {
                active: false
                description: "Custom 3",
                name: "custom3"
            }
        ];
    }
});

my view html

{{#each checkboxes}}
<p>
    {{#if active}}
        <input type="checkbox" name="actions[]" checked="checked"  />
   {{else}}
       <input type="checkbox" name="actions[]"  />
  {{/if}}
</p>
{{/each}}

It works well (all my checkboxes are not checked). When i change my reactive var Session.set(‘mode’, ‘create’); e.g.
it also works correctly, but! if I manually check some of checkboxes and change my reactive var list of checkboxes updated but some of them are checked! The question is : Why ? I make them unchecked " active: false"
But meteor ignores my setting and restore the previous state of checkboxes. How to prevent this behavior?


#2

What exactly do you want to do? Maybe we can help you understand how to code your requirement.

As it stands, that code will be working exactly as you have written it, and it doesn’t look like it will do anything useful.


#3

Thank you, I have already fixed this trouble