I am assigning this custom snippet to a currency field. My objective is to place commas in the appropriate places as the user is typing. But for now the code is trying to replace the value of 2000 into the field whenever a character is entered into the input.
There are two issues I am having with the code below:
- The change event seems to only activate after I click out of the field. I would actually like this action to re-evaluate the fields value each time a character is entered or deleted.
- The field is added over and over and over again each time the function is run rather than updating the value and refreshing the existing field.
var $ = skuid.$;
var field = arguments[0];
var value = arguments[1];
model = field.model, row=field.row, $=skuid.$;
field.element.change(function(value){
value = 2000;
skuid.ui.fieldRenderersrfield.metadata.displaytype]‘edit’;
});
skuid.ui.fieldRenderersefield.metadata.displaytype]‘edit’;