Skip to content

Commit

Permalink
Limit description field in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Cobby committed Oct 10, 2012
1 parent e55ccc9 commit bb8682b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions web/js/views/SaveBudgetPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ TGM.Views.SaveBudgetPane = TGM.Views.SidePane.extend({
this.on('shown', this.onShow);

// cache inputs
this.$name = this.$('.your-name-wrapper input');
this.$state = this.$('.your-name-wrapper select');
this.$email = this.$('.your-email-wrapper input');
this.$name = this.$('.your-name-wrapper input');
this.$state = this.$('.your-name-wrapper select');
this.$email = this.$('.your-email-wrapper input');
this.$description = this.$('.budget-description-wrapper textarea');
this.$subscribe = this.$('.subscribe-wrapper input');
this.$saveButton = this.$("#submit-save-budget");
this.$subscribe = this.$('.subscribe-wrapper input');
this.$saveButton = this.$("#submit-save-budget");

// update form when the model changes (normally from cache restore)
this.model.on('change', this.modelChanged);
Expand Down Expand Up @@ -60,12 +60,17 @@ TGM.Views.SaveBudgetPane = TGM.Views.SidePane.extend({

formToJson: function()
{
return {
var json = {
name: this.$name.val(),
state: this.$state.val(),
email: this.$email.val(),
description: this.$description.val()
}

if (json.description.length > 500) {
json.description = json.description.substr(0, 500);
this.$description.val(json.description);
}
},

reset: function(e)
Expand Down Expand Up @@ -177,6 +182,7 @@ TGM.Views.SaveBudgetPane = TGM.Views.SidePane.extend({

formUpdate: function()
{
var json = this.formToJson();
this.model.set(this.formToJson());
this.model.cache();
},
Expand Down

0 comments on commit bb8682b

Please sign in to comment.