Reputation: 861
checkbox event:
<input type="checkbox" name="contents" value="1" {{action 'enable_submit'}} />
submit button
<button id='submit_btn' class='btn' disabled="disabled">Submit</button>
when user click checkbox, remove disabled of submit button
$("#submit_btn").removeAttr('disabled')
The result is:
1, disable status of submit button can be removed normally.
2, the checkbox can't be checked again, it is the same problem on radiobutton
Upvotes: 1
Views: 1157
Reputation: 23322
Have a look at this jsbin for a possible implementation.
Basically every time the checked status of the checkbox changes it triggers the disabled status of the button. This is possible due to the two-way binding ember.js provides for you.
Here the view:
App.IndexView = Ember.View.extend({
disabled: false
});
The checkbox:
{{view Ember.Checkbox checkedBinding="view.disabled"}}
The button:
{{#view Ember.Button class='btn btn-warning' disabledBinding="view.disabled"}}Submit{{/view}}
This binding behavior can also be defined somewhere else, I've put it on the view for the sake of simplicity.
Hope it helps.
Upvotes: 1