Skip to content

Instantly share code, notes, and snippets.

@elchele
Created February 21, 2015 03:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchele/b558e6c6a57dccc7dd05 to your computer and use it in GitHub Desktop.
Save elchele/b558e6c6a57dccc7dd05 to your computer and use it in GitHub Desktop.
Custom controller for automatically uppercasing last_name value when field loses focus
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/<Module>/clients/base/views/record/record.js
*
* Custom RecordView controller for automatically converting
* last_name value to upper when focus is lost
*/
extendsFrom:'RecordView',
initialize: function(options){
this._super('initialize', [options]);
//Add event that listens for blur event on last_name field
this.events['blur input[name=last_name]'] = 'doUpperLast';
},
doUpperLast: function(){
//Get current value of last_name
var sLast = this.model.get('last_name');
//Convert last_name value to upper if not empty
if (!_.isEmpty(sLast))
{
this.model.set('last_name', sLast.toUpperCase());
}
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment