An ember-cli addon for using SweetAlert2 in Ember applications.
In your application's directory:
ember install ember-sweetalert
The sweet-alert
component allows setting SweetAlert's attributes.
You can import SweetAlert easily with:
import sweetAlert from 'ember-sweetalert';
The SweetAlertMixin allows you to use the SweetAlert2 library with the attribute sweetAlert
.
import Ember from 'ember';
import SweetAlertMixin from 'ember-sweetalert/mixins/sweetalert-mixin';
const { Controller } = Ember;
export default Controller.extend(SweetAlertMixin, {
actions: {
submit() {
let sweetAlert = this.get('sweetAlert');
sweetAlert({
title: 'Submit email to run ajax request',
input: 'email',
showCancelButton: true,
confirmButtonText: 'Submit',
allowOutsideClick: false
}).then((confirm)=> {
// ...
});
}
}
});
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.