Skip to content

Instantly share code, notes, and snippets.

@jimrubenstein
Created January 29, 2014 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimrubenstein/8691008 to your computer and use it in GitHub Desktop.
Save jimrubenstein/8691008 to your computer and use it in GitHub Desktop.
var Entry = (function($) {
function Entry(attributes) {
this.attributes = attributes;
}
Entry.prototype.get = function(attr) {
return this.attributes[ attr ] || null;
}
return Entry;
})(jQuery);
var EntryForm = (function($) {
function EntryForm($container)
{
this.$container = $(container);
this.delegateEvents();
}
EntryForm.prototype.delegateEvents = function()
{
var self = this;
this.$container.find('#createEntry').click(function(evt)
{
self.createEntry.call(self);
});
}
EntryForm.prototype.createEntry = function()
{
var e = new Entry(this.serializeForm());
}
EntryForm.prototype.serializeForm = function()
{
var attr = {
jobNumber: $('#jobNumber').val(),
hours: splitHourText($('#hours').text())
};
return attr;
}
/* private methods */
function splitHourText(text)
{
return text.split(' ')[0];
}
})(jQuery);
(function($) {
$(document).ready(function()
{
var eForm = new EntryForm($('#form_container'));
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment