AnsweredAssumed Answered

Set value of text field on keyup

Question asked by Paul Carlton on May 11, 2016
Latest reply on Mar 11, 2017 by Bao Tran Hoang

What I'm trying to do is pretty simple.  However trying to get this to work with the system seems far more complicated and nuanced than it should be.


On a subpanel, a field needs to be formatted a certain way.  So on keyup after a certain amount of characters (like a phone number for example) needs to include some formatting, then the field needs to update with that value, and then I should be able to save it.  For some reason everything that I'm doing DOES NOT WORK.  Something as simple as $('#val').val('my new val') ruins everything, the subpanel doesn't even save anything anymore after I put that in.  It's really weird.


I've tried this.model.set({'key':'val'}); Doesn't work.  I've tried simply replacing the value.  Doesn't work.  Nothing anybody has said on this forum works.  I also checked some questions on this for backbone.  Nothing answers this question, so it's got to be something stupid right?  Something blindingly nuanced but easy that I'm just overlooking for this????


I'm basically firing off an even on initialize of a subpanel with this.context.on('list:editrow:fire', this.checkFormats, this);


Then this.checkFormats sets keyup on a field by it's name.  So if the name matches ssn_c for instance, then ssn_c will have a keyup(function() {}) that checks the format on each keyup and then replaces the value of the field with a formatted value.  How do you do that with the ability to save the input AND the ability to view what has been changed in the input???  Right now, nothing works.  Please advise.