Skip to content

Commit

Permalink
Initialize required options on the place forms
Browse files Browse the repository at this point in the history
  • Loading branch information
mjumbewu committed May 31, 2016
1 parent ed7b9af commit f1a831c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/sa_web/static/js/views/place-form-view.js
Expand Up @@ -27,6 +27,7 @@ var Shareabouts = Shareabouts || {};
}, S.stickyFieldValues, this.model.toJSON());

this.$el.html(Handlebars.templates['place-form'](data));
this.updatedRequiredOptionButtons();
return this;
},
remove: function() {
Expand Down Expand Up @@ -101,14 +102,24 @@ var Shareabouts = Shareabouts || {};
});
}
},
onRequiredOptionButtonChange: function(evt) {
var groupName = $(evt.currentTarget).attr('name');
var groupOptions = this.$('[name="' + groupName + '"]');
if (groupOptions.is(':checked')) {
groupOptions.removeAttr('required');
} else {
groupOptions.attr('required', 'required');
updatedRequiredOptionButtons: function(optionButtons) {
var groupNames = []

this.$(optionButtons || '[data-group-required]').each(function(index, btn) {
groupNames.push($(btn).attr('name'));
}

_.chain(groupNames).uniq().each(function(groupName) {
var groupOptions = this.$('[name="' + groupName + '"]');
if (groupOptions.is(':checked')) {
groupOptions.removeAttr('required');
} else {
groupOptions.attr('required', 'required');
}
}, this);
},
onRequiredOptionButtonChange: function(evt) {
this.updatedRequiredOptionButtons(evt.currentTarget)
},
onSubmit: Gatekeeper.onValidSubmit(function(evt) {
// Make sure that the center point has been set after the form was
Expand Down

0 comments on commit f1a831c

Please sign in to comment.