Sha256: ff0c5143a3b58906bf45744125b3bac18f972f2fba844652c49bce88f949b9f0

Contents?: true

Size: 501 Bytes

Versions: 24

Compression:

Stored size: 501 Bytes

Contents

export default class {
  connect() {
    var $clearBtn = $('.btn-reset');
    var $input = $clearBtn.parent().prev('input');
    var btnCheck = function(){
      if ($input.val() !== '') {
        $clearBtn.css('display', 'inline-block');
      } else {
        $clearBtn.css('display', 'none');
      }
    };

    btnCheck();
    $input.on('keyup', function() {
      btnCheck();
    });

    $clearBtn.on('click', function(event) {
      event.preventDefault();
      $input.val('');
    });
  }
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-spotlight-3.6.0.beta5 app/javascript/spotlight/user/clear_form_button.js
blacklight-spotlight-3.6.0.beta4 app/javascript/spotlight/user/clear_form_button.es6
blacklight-spotlight-3.6.0.beta3 app/javascript/spotlight/user/clear_form_button.es6
blacklight-spotlight-3.6.0.beta1 app/javascript/spotlight/user/clear_form_button.es6