Last active
May 29, 2020 18:54
-
-
Save hotsoft-desenv4/fe8768f91acd2b647c4163447db9d909 to your computer and use it in GitHub Desktop.
Glimerless controllfreak functional redirectioninzing full version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/components/marcas/marcas-form.js | |
import Component from '@ember/component'; | |
export default Component.extend({ | |
//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 | |
actions: { | |
saveMarca(marca) { | |
let selfthis = this; | |
marca.save().then( function() { | |
selfthis.sendAction('redirectTo'); | |
}); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/components/marcas/marcas-index.js | |
import Component from '@ember/component'; | |
export default Component.extend({ | |
actions: { | |
deleteMarca(marca) { | |
marca.destroyRecord(); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/routes/marcas/new.js | |
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model() { | |
return this.store.createRecord('marca'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment