Skip to content

Instantly share code, notes, and snippets.

@GabrielCW
Created February 29, 2016 15:07
Show Gist options
  • Save GabrielCW/5ec8c71bf3eea1784906 to your computer and use it in GitHub Desktop.
Save GabrielCW/5ec8c71bf3eea1784906 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Mixin.create({
deactivate: function() {
var model = this.get('controller.model');
model.rollbackAttributes();
if (model.get('isNew')) {
model.deleteRecord();
}
},
beforeTransition: function(transition){
var model = this.get('controller.model');
if (model.get('hasDirtyAttributes')) {
transition.abort();
swal({
title: "Attention",
text: "Êtes-vous sûr de vouloir effectuer cette action ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Confirmer",
closeOnConfirm: true
},
function(isConfirm){
console.log(isConfirm);
console.log(transition);
//transition.retry();
if(isConfirm)
transition.retry();
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment