Skip to content

Instantly share code, notes, and snippets.

@misutowolf
Created April 21, 2015 14:33
Show Gist options
  • Select an option

  • Save misutowolf/8f21ce3c5ed81ccce04a to your computer and use it in GitHub Desktop.

Select an option

Save misutowolf/8f21ce3c5ed81ccce04a to your computer and use it in GitHub Desktop.
ET Callback for Currency stuff
EditableText.registerCallbacks({
// Callback for editing category limit/budget.
budgetCurrency: function(doc) {
// Variables based on editing.
var oldVal = this.oldValue;
var newVal = this.newValue;
// Verification:
if (isNaN(newVal)) {
// Reject value if not a number, don't make change.
doc.limit = oldVal;
} else {
doc.limit = Number(newVal).toFixed(2);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment