Skip to content

Instantly share code, notes, and snippets.

@hotsoft-desenv4
Created May 29, 2020 17:42
Show Gist options
  • Save hotsoft-desenv4/94188f496294dfecdfe98cd0b9b7288f to your computer and use it in GitHub Desktop.
Save hotsoft-desenv4/94188f496294dfecdfe98cd0b9b7288f to your computer and use it in GitHub Desktop.
rsvp.js:23 Uncaught TypeError: selfthis.redirectTo is not a function
at marcas-form.js:14
at tryCatcher (rsvp.js:335)
at invokeCallback (rsvp.js:506)
at publish (rsvp.js:492)
at rsvp.js:16
at invoke (backburner.js:335)
at Queue.flush (backburner.js:226)
at DeferredActionQueues.flush (backburner.js:423)
at Backburner._end (backburner.js:957)
at Backburner.end (backburner.js:707)
app/components/marcas/marcas-form.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class MarcasFormComponent extends Component{
@tracked redirectTo;
//https://guides.emberjs.com/v3.3.0/components/triggering-changes-with-actions/
//https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/closure-actions.md
@action
saveMarca(marca) {
let selfthis = this;
marca.save().then( function() {
selfthis.redirectTo();
});
}
}
app/templates/marcas/new.hbs
<h2>Criar nova marca</h2>
{{!-- https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/closure-actions.md --}}
<Marcas::MarcasForm @model={{model}} @redirectTo={{action "redirectTo"}} />
app/controllers/marcas/new.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class MarcasNewController extends Controller {
@action
redirectTo() {
this.transitionToRoute("/marcas");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment