Sha256: a275db9dda42bdfa4913399edb3fd97403dbdfc3792032dcb9a68857b69a2205

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

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.hide();
  $hidden.slideDown();

  return false; // This implicitly calls event.preventDefault() to cancel the action, and prevent the link from going somewhere.
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_bootstrap-0.3.14 app/assets/javascripts/effective_select_or_text/initialize.js
effective_bootstrap-0.3.13 app/assets/javascripts/effective_select_or_text/initialize.js