show-when-this

0.1.1 • Public • Published

Build Status

Show when this

jQuery plugin to manage conditional showing/hiding of elements.

## Usage

<div id="radio_buttons">
  <input type="radio" name="show_additional_information" value="show" />
  <input type="radio" name="show_additional_information" value="hide" checked="checked" />
  <div class="additional_information">
    Showing #radio_buttons .additional_information
  </div>
</div>

<script>
  $('#radio_buttons .additional_information').showWhenThis( {
    evaluator_callback: function(){ return $('#radio_buttons input[name="show_additional_information"]:checked').val() == '1' },
    change_selector: $('[name="show_additional_information"]')
  });
</script>

You can find other usage examples in the repo.

Options

  • evaluator_callback - A function that should return true or false. When true the element the plugin is attached to will be shown, otherwise it'll be hidden.
  • change_selector - The selector that when changed will trigger the rerunning of evaluator_callback.

Installing

Copy the show-when-this.min.js file into your project and link it up.

Getting going with Zepto

If you are using this plugin with Zepto instead of jQuery, make sure you include the modules zepto event data selector in your build.

Thanks

@Krinkle - For an good example on how to setup CI for JS projects.

Package Sidebar

Install

npm i show-when-this

Weekly Downloads

0

Version

0.1.1

License

none

Last publish

Collaborators

  • mikerogers0