Reputation: 1386
Using Onsen 2.0 with Monaca, I am having an issue setting the disable property to true via JavaScript and not Angular. I am aware of how to do this with AngularJS and binding to a variable, but I just need to set the property via straight JS as this project is not using AngularJS at all. I fear this may not be possible.
Here is the code which does not work:
<ons-button id="btn">Stop</ons-button>
<ons-button onclick="document.getElementById('myBtn').disabled = true;">Go</ons-button>
Edit: Huge thank you to Fran again for solving my issue. For others, since this is simply setting the CSS, to disable the button:
document.getElementById("myButton").setAttribute('disabled', '');
and to re-enable it after using setAttribute:
document.getElementById("myButton").removeAttribute('disabled', '');
Upvotes: 2
Views: 319
Reputation: 3482
disabled
is not an internal variable, it's just an attribute used to apply some CSS. Try with document.getElementById('myBtn').setAttribute('disabled', '')
.
Upvotes: 2