-
Notifications
You must be signed in to change notification settings - Fork 199
Button's disabled attribute cannot be set conditionally #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's actually expected behavior at the moment, adding a boolean value to something will make the actual value of it that boolean. It doesn't conditionally render. The only item that is treated special is classes, for example: <!-- array of classes in m-literal applies all of them during a build -->
<h1 m-literal:class="['bar', 'baz']">Foo</h1>
<!-- object of classes conditionally adds them -->
<h1 m-literal:class="{bar: true, baz: false}">Foo</h1> I guess I can add behavior to the prop diff to conditionally add elements if they are a boolean. It'll be coming in v0.9.0. |
@kingpixil Many thanks for your prompt replies over the last day. I'm a user of VueJS, but the speed and size of your framework is really intriguing to me. Might this conditional HTML attribute rendering also extend to things such as "checked" and "selected"? |
@bovisp No problem! I can't thank you enough for the great feedback you give, it really helps. After I fix a couple more bugs, v0.9.0 will be out! 🎉 Yup! The conditional HTML attributes work for anything provided as a boolean, including component properties as well! |
@kingpixil I'm happy to help. I'm in the process of creating some Moon examples using a codepen project. I'm basically retaking Laracasts' Vue 2.0 Step-by-Step and then Moon-ifying the resulting code. It will take me a while. The project is in very rough shape right now and I only have four "hello world" type examples so far. They will be building in complexity as I move through the tutorials. I'll be renaming the HTML files and creating a landing page soon. The link is: https://codepen.io/tcdd/project/editor/ZoyVqA/ |
And I was able to get conditional classes working via |
That's super cool! Love the examples 👍 |
Has this been fixed? Still having this issue with 0.10.0 |
node.removeAttribute(nodePropName); is trying to remove property m-literal:disabled instead of disabled. Any idea how this is possible? |
Ahh, thank you for bringing this to my attention. The condition was removed in some previous commit, it should be fixed in v0.11.0. |
Description
I am trying to conditionally trying to set the
disabled
attribute on a button, but this doesn't seem to be working. I should be able to do this by usingm-literal:disabled
and set that equal to a Boolean data property.Steps to Reproduce
Expected behavior
Before I even click the button to trigger the event, the above HTML should render to:
As
isDisabled
is initially set to false, the disabled attribute should not appear at all.On click, we should get the following:
Actual behavior
Before I even click the button to trigger the event, the above HTML actually renders to:
and the button appears as disabled.
This is probably not a bug. The bug may actually be the human (i.e. me). Suggestions?
The text was updated successfully, but these errors were encountered: