Giter Club home page Giter Club logo

iqtoggle's Introduction

iQToggle

Build Status

iQToggle is a jQuery plugin to provide a declarative way for conditionally controlling the visibility of elements.

Getting Started

Download the production version or the development version.

In your web page:

<script src="jquery.js"></script>
<script src="iqtoggle.min.js"></script>
...
<select id="source">
    <option value="good">Good decision</option>
    <option value="better">Better decision</option>
    <option value="best">Best decision</option>
</select>
<span id="conditional">Whooho! You made best best decision!</span>

<script>
    $("#conditional").toggleIfSelected("#source option[value='best']");
</script>

iQToggle will now subscribe to the change events of the #source select box and will hide the #conditional span unless the Best decision has been chosen. This works as well for radio buttons and checkboxes.

Documentation

(Coming soon)

Examples

Using iQToggle with semantic markup

<select id="source">
    <option value="good">Good decision</option>
    <option value="better">Better decision</option>
    <option value="best">Best decision</option>
</select>
<span id="conditional" data-show-if-selected="#source option[value='best']">Whooho! You made best best decision!</span>

<script>
	// put this to your glue code
    $(function() {
		$("[data-show-if-selected]").each(function(i, node) {
			var el = $(node);
			var selector = el.data("show-if-selected");
			el.toggleIfSelected(selector);
		});
	});
</script>

This code snippet will connect all elements that are annotated with a data-show-if-selected attribute to the selection source that is given in the attribute.

(More coming soon)

Release History

(Nothing yet)

License

Copyright 2012-2014 innoQ Deutschland GmbH. Licensed under the Apache License, Version 2.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Please don't edit files in the dist subdirectory as they are generated via grunt. You'll find source code in the src subdirectory!

While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the test/*.html unit test file(s) in actual browsers.

  • npm install install development dependencies
  • grunt dependencies downloads third-party components
  • grunt test runs the test suite
  • grunt dist creates release files

Or run all grunt-taks by calling grunt. Add --verbose option to get detailed output.

iqtoggle's People

Contributors

fnd avatar mjansing avatar vanto avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.