knownasilya/ember-toggle

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

runspired opened this issue · 2 comments

<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)}}
    />

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)}}>

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.