Created
February 21, 2015 03:03
-
-
Save elchele/b558e6c6a57dccc7dd05 to your computer and use it in GitHub Desktop.
Custom controller for automatically uppercasing last_name value when field loses focus
This file contains hidden or 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
({ | |
/* Author: Angel Magaña -- [email protected] | |
* 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