knownasilya / ember-toggle

Checkbox based Toggle Switches for Ember
http://knownasilya.github.io/ember-toggle/
MIT License
112 stars 52 forks source link

Toggle does not work if placed within a <form {{action}}> #119

Closed runspired closed 4 years ago

runspired commented 6 years ago
<form {{action "onSubmit"}}>
  {{!-- this does not work }}
  <XToggle
      @value={{guest.isInvited}}
      @onToggle={{action (mut guest.isInvited) (not guest.isInvited)}}
    />
</form>
{{!-- this works }}
<XToggle
      @value={{guest.isInvited}}
      @onToggle={{action (mut guest.isInvited) (not guest.isInvited)}}
    />
runspired commented 6 years ago

This can be worked around by using <form onsubmit={{action "foo"}}> directly and preventing the default form behavior manually.

For more complex things:

{{!-- the last value given to myAction will now be the event}}
<form onsubmit={{action (action myAction someParam)}}>
knownasilya commented 5 years ago

I don't think this is a bug, because the first version should actually be

<form {{action "onSubmit" on="submit"}}>
  <XToggle
      @value={{guest.isInvited}}
      @onToggle={{action (mut guest.isInvited) (not guest.isInvited)}}
    />
</form>

Even template-lint complains if that's not there.