Created
February 29, 2016 15:07
-
-
Save GabrielCW/5ec8c71bf3eea1784906 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
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