Last active
April 18, 2018 08:18
-
-
Save RobinKuiper/ce48b3f61cdee1d82d202748508ddb9a 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
// Fire when the turnorder is changed. | |
on('change:campaign:turnorder', (obj, prev) => { | |
// Check if the turnorder is changed, otherwise cancel | |
if(obj.get('turnorder') === prev.turnorder) return; | |
// Parse the turnorder to an object, and sort it Ascending. | |
let turnorder = JSON.parse(obj.get('turnorder')).sort((a,b) => { return a.pr - b.pr }); | |
// Set the new turnorder order. | |
obj.set('turnorder', JSON.stringify(turnorder)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment