Skip to content

Instantly share code, notes, and snippets.

@jchannon
Forked from timbjames/Simple Javascript app v2
Created January 22, 2013 14:52
Show Gist options
  • Save jchannon/4595214 to your computer and use it in GitHub Desktop.
Save jchannon/4595214 to your computer and use it in GitHub Desktop.
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