How to disable a bootstrap button in Vue 1.0
Ok, very simple question here:
How would I get vue to help me do this when a computed property is true:
<button class="btn">
and this when it if false:
<button class="btn" disabled>
Seems like such a simple task and I'm sure I've come across this before, help please?
Thanks,
Caleb
You can do something like this
<input v-model="agree" type="checkbox" /> Agree to this
<button v-attr="disabled: !agree">Submit</button>
var app = new Vue({
el: '#app',
data: {
agree: false
}
});
So when the check box is checked, agree will be true and therefore the button will be enabled. The button will now be disabled by default
@bobbybouwmann : Thanks for the suggestion, however the "v-attr" directive is not available in Vue 1.0
Thanks,
Caleb
Found the solution:
<button class="btn" :disabled="someComputedProperty">
if "someComputedProperty" resolves to true, the disabled attr will show up, if false it won't.
Thanks,
Caleb
Oow yeah sorry, it's from the old vue :P
Please or to participate in this conversation.