Commit a7dfa57747f5bb89e37379bd7da1077b7f33d519

Authored by Stephen Crosby
1 parent 4f4dddbe
Exists in master and in 1 other branch production

scope the type selector to the choose section

Formerly if any input in the sub-menus had the substring 'type' in its
name, this event handler would have been bound to clicks on the input
element. When this happens, the variable 'chosen' would generally be an
empty string and that would result in an erroneous jQuery finder:
wrapper.find('div.'+section_class+'.'+chosen) causing an unhandled
error.

It looks like the intent is to bind only to the selectable choice icons,
so that's what this commit does and as a bonus, the embedded forms can
now have an input with the word 'type' in its name.
Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
app/assets/javascripts/form.js
@@ -81,7 +81,7 @@ function activateTypeSelector(field_class, section_class) { @@ -81,7 +81,7 @@ function activateTypeSelector(field_class, section_class) {
81 $('div.'+field_class+' > div.'+section_class).not('.chosen').find('input') 81 $('div.'+field_class+' > div.'+section_class).not('.chosen').find('input')
82 .attr('disabled','disabled').val(''); 82 .attr('disabled','disabled').val('');
83 83
84 - $('div.'+field_class+' input[name*=type]').on('click', function(){ 84 + $('div.'+field_class).find('.choose input[name*=type]').on('click', function(){
85 // Look for section in 'data-section', and fall back to 'value' 85 // Look for section in 'data-section', and fall back to 'value'
86 var chosen = $(this).data("section") || $(this).val(); 86 var chosen = $(this).data("section") || $(this).val();
87 var wrapper = $(this).closest('.nested'); 87 var wrapper = $(this).closest('.nested');