Skip to content
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

Boolean attributes #238

Closed
nathnolt opened this issue Sep 11, 2018 · 1 comment
Closed

Boolean attributes #238

nathnolt opened this issue Sep 11, 2018 · 1 comment

Comments

@nathnolt
Copy link

It doesn't seem to be possible to set boolean arguments based on state.

Example

<input disabled>

but having disabled based on state, so something like

<input ={disabledinput?'disabled':''}>

I want this for select options.

If this is in fact possible, then it wasn't clear to me from reading the docs (Or I missed it).

Thank you.

@s-melnikov
Copy link

<script type="text/mvl" id="template">
    <input If={disabled} type="text" disabled/>
    <input Else type="text"/>
    <button @click={toggle()}>Toggle</button>
  </script>

  <script>
    Moon({
      root: "#app",
      view: document.getElementById("template").innerHTML,
      disabled: false,
      toggle() {
        this.update({disabled: !this.disabled});
      }
    });
  </script>

@kbrsh kbrsh closed this as completed in acd98dc Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants