GithubHelp home page GithubHelp logo

rixth / customradio Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 0.0 124 KB

A simple jQuery UI widget to pretty up radio elements.

Home Page: http://rixth.github.com/customRadio/

License: MIT License

JavaScript 100.00%

customradio's Introduction

jquery.customRadio

A simple jQuery UI widget to pretty up radio elements. There is a suite of unit tests available in test/, written with Jasmine. You can see an example and run the tests on the plugin's website.

Since it works by manipulating and reading the events right off your native radio inputs, it fully respects tabbing and keyboard navigation/selection of items. This also means you can call the standard jQuery val methods, bind to the change event, etc right on the native element.

It also respects the disabled attribute and works with labels.

HTML structure required

<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="undisclosed"> Undisclosed<br>

And then...

$('input[type=radio]').customRadio();

CSS classes

All the display is powered by CSS, check out src/jquery.customRadio.css for ideas, and then customize to your heart's content. Here are the four classes you need to implement:

  • ui-radioButton (default state)
  • ui-radioButton-checked
  • ui-radioButton-focus
  • ui-radioButton-disabled

Methods

  • destroy: remove the pretty widget, unbind events and show the original radio
  • disable: disable the widget, just like you would disable a radio button
  • enable: allow interaction with the widget after disabling it

Events

You should bind to the change event on the native input element.

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.