Skip to content

Instantly share code, notes, and snippets.

@chrismllr
Created February 11, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismllr/05a12ce0c036e914606dba9a724241d5 to your computer and use it in GitHub Desktop.
Save chrismllr/05a12ce0c036e914606dba9a724241d5 to your computer and use it in GitHub Desktop.
Confirm action - Usage
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default Controller.extend({
confirmAction: service(),
api: service(),
async deleteRecord(record) {
try {
const result = await this.confirmAction.ask({
title: 'Are you sure?',
message: 'This action cannot be undone!'
});
if (result) {
await this.api.deleteRecord(record.id);
}
} catch (err) {
// eslint-disable-next-line no-console
console.error('Error deleting record', err);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment