First attempt:
<button type="submit" class="button" {{#if isDirty(item)}}disabled{{/if}}>Save2</button>
causes an error during compile:
bundling...
🚨 (svelte plugin) Error: (28:75) Expected >
26: <div class="row">
27: <!-- FIXME Can't set an attribute dynamically? -->
28: <button type="submit" class="button" {{#if isDirty(item)}}disabled{{/if}}>Save2</button>
^
The best I could come up with:
{{#if isDirty(item)}}
<button type="submit" class="button" disabled>Save</button>
{{else}}
<button type="submit" class="button">Save</button>
{{/if}}
Svelte 'fixes' HTML so that the disabled
attribute (and other boolean attributes) behave more sanely:
<button type="submit" class="button" disabled='{isDirty(item)}'>Save</button>
Demo here.
EDIT: Updated example and Demo to Svelte 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With