Created
January 22, 2013 14:50
-
-
Save timbjames/4595190 to your computer and use it in GitHub Desktop.
This file contains 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
var defaults = { | |
selectors: { | |
fullname: "#fullname", | |
firstname: "#firstname", | |
lastname: "#lastname" | |
} | |
}; | |
var nameConcatenater = function (options) { | |
var self = this; | |
self.options = $.extend({}, defaults, options); | |
self.setBindings = function () { | |
var self = this; | |
$(self.options.selectors.firstname).on('keyup', function () { | |
self.updateFullname(); | |
}); | |
}; | |
self.updateFullname = function () { | |
var self = this; | |
var firstname = $(self.options.selectors.firstname).val(); | |
$(self.options.selectors.fullname).text(firstname); | |
}; | |
self.setBindings(); | |
}; | |
$(function () { | |
var instance = new nameConcatenater(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment