Created a new ember octane app (3.15) and using ember-bootstrap with it. I am using a modal like so
<BsModalSimple
@open={{true}}
@title="Create new podcast"
@closeTitle="Cancel"
@submitTitle="Create"
@size="lg"
@closeButton={{false}}
@fade={{false}}
@backdrop={{true}}
@backdropClose={{false}}
@renderInPlace={{false}}
@onHidden={{action 'closeModal'}}
@position="center">
</BsModalSimple>
This works but I get an error which says
Do not use
actionas {{action ...}}. Instead, use theonmodifier andfnhelper.
What's the right way to use an action in this scenario? I've tried this but it didn't work
{{on 'hidden' this.closeModal}}
In classic Ember model (pre-octane), the
{{action}}helper was used to bind the properthiscontext to the action/method that is being passed as a closure action. So, when the closure action is called inside any class, the action will have the caller'sthiscontext not the callee.To be more predictable and explicit, this context binding was moved as a decorator, @action which should be used to decorate your
closeModalmethod instead of using the{{action}}helper in the template. So, your code can be:Please note that the error was thrown by the linter (ember-template-lint) and the error message can be more explicit to use the @action decorator.