Vheissu / aurelia-for-real-world-web-applications-book-feedback

Post feedback as issues here on Github for the Aurelia book. Be as descriptive and honest as you like.
15 stars 0 forks source link

Persisting Form Data Checkbox Example? #46

Closed vimcat closed 8 years ago

vimcat commented 8 years ago

adding click.delegate to a form with a single checkbox whose value is true/false to saveField causes the checkbox to stop working.

formValues.myCheckbox = false;
<input type="checkbox" checked.bind="formValues.myCheckbox"  click.delegate="saveField(myCheckbox, $event.target.value)"  /> // sets the value to 'on' and checkbox stops working
<input type="checkbox" checked.bind="formValues.myCheckbox"  click.delegate="saveField(myCheckbox, !formValues.myCheckbox)"  /> // toggles T/F and checkbox stops working

What's the proper way to do it? Thanks!

wshayes commented 8 years ago

Return true from the save field method

On Mar 31, 2016, at 16:11, Veronica Canterbury notifications@github.com wrote:

adding click.delegate to a form with a single checkbox whose value is true/false to saveField causes the checkbox to stop working.

formValues.myCheckbox = false; // sets the value to 'on' and checkbox stops working // toggles T/F and checkbox stops working What's the proper way to do it? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

Vheissu commented 8 years ago

What @wshayes said is the correct way to make the event continue, otherwise default behaviour is to prevent the default action.