Sha256: 9b7aaf45f0644dca018efaacd6c494330688f2468b3e61400d04842ac58ae102
Contents?: true
Size: 1.21 KB
Versions: 231
Compression:
Stored size: 1.21 KB
Contents
$(document).on('change', '.effective-select-or-text input', function(event) { $(event.currentTarget).closest('.effective-select-or-text').find('select').val('').trigger('change.select2'); }); $(document).on('change', '.effective-select-or-text select', function(event) { $(event.currentTarget).closest('.effective-select-or-text').find('input').val(''); }); // This is the icon that switches them $(document).on('click', '[data-effective-select-or-text]', function(event) { $obj = $(event.currentTarget).closest('.effective-select-or-text'); $visible = $obj.children('.form-group:visible').first(); $hidden = $obj.children('.form-group:not(:visible)').first(); $visible_input = $visible.find('input,textarea,select').first() $hidden_input = $hidden.find('input,textarea,select').first() required = $visible_input.prop('required') || $hidden_input.prop('required') $hidden_input.prop('required', required) $visible_input.removeAttr('required') $visible.fadeOut('fast', function() { $hidden.prop('required', required).detach().insertAfter($visible).fadeIn('fast'); }); return false; // This implicitly calls event.preventDefault() to cancel the action, and prevent the link from going somewhere. });
Version data entries
231 entries across 231 versions & 1 rubygems