Last active
May 28, 2020 23:53
-
-
Save hotsoft-desenv4/6b19fae4cb32ad19725b4cdaf8cce5f8 to your computer and use it in GitHub Desktop.
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/routes/marcas/new.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/routes/marcas/new.js | |
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model() { | |
return this.store.createRecord('marca'); | |
}, | |
//https://guides.emberjs.com/v1.12.0/components/sending-actions-from-components-to-your-application/ | |
actions: { | |
redirectTo: function() { | |
this.transitionTo("marcas"); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment