/plugins/forms-controls/select2Buttons/README.md

https://bitbucket.org/vins13pattar/handpicked.jquery.plugins.repo · Markdown · 74 lines · 50 code · 24 blank · 0 comment · 0 complexity · b93f336f23d3388b64c86e786d919f95 MD5 · raw file

  1. # Select2Buttons JQuery Plugin
  2. ## About
  3. Select2Buttons is a jQuery plugin that provides an alternative to the standard html select. The plugin converts selects into a series of button like elements,
  4. and if used correctly can provide a better visual representation of the options available to a user.
  5. [![select to buttons example](http://o-sam-o.github.com/images/select2ButtonsExample.png)](http://o-sam-o.github.com/select2Buttons/)
  6. [DEMO AVAILABLE HERE](http://o-sam-o.github.com/select2Buttons/)
  7. This plugin was inspired by [threadless.com](http://www.threadless.com/) and a question by [GreatPotato](http://forrst.com/people/GreatPotato) on Forrst.
  8. ### Features
  9. * Converts normal HTML selects into button like elements (a tags)
  10. * Supports JS change callbacks
  11. * Supports disabled options
  12. * Supports disabled selects
  13. * Supports OptGroups
  14. * Allows no default selection (like threadless)
  15. ## Howto
  16. Add a standard select to the page and then make 1 jQuery call to convert it into buttons:
  17. <select name="simple-select">
  18. <option>One</option>
  19. <option>Two</option>
  20. <option>Three</option>
  21. </select>
  22. <script>
  23. $('select[name=simple-select]').select2Buttons();
  24. </script>
  25. When the user clicks on one of the buttons (their really links), the plugin sets that value in your select so server side your code should be exactly the same.
  26. ### Javascript Callbacks
  27. Any change events registered against the original select will also fire when the select buttons are clicked. e.g.
  28. $('select[name=simple-select]').change(function() {
  29. alert('Changed to ' + $(this).val());
  30. });
  31. ### No Default Selection
  32. By default the option selected in your select will be marked as selected
  33. in the buttons. However, the plugin also supports the threadless style,
  34. no default selection.
  35. $('select[name=simple-select]').select2Buttons({noDefault: true});
  36. ### OptGroups
  37. The plugin understands and honors option groups. Each option group will
  38. be placed in a seperate UL and the optgroups label will be added to the
  39. page as a strong tag.
  40. ### Disabling
  41. The plugin supports disabled options and disabled selects. [See the demo
  42. for examples.](http://o-sam-o.github.com/select2Buttons/)
  43. ### Styling
  44. The select2Buttons.css is provided as a guide, it's mostly copied from
  45. threadless.com. I suggest restyling if your going to use the plugin on a
  46. commercial site.
  47. ## Licencing
  48. MIT
  49. ## Contact
  50. Sam Cavenagh [(cavenaghweb@hotmail.com)](mailto:cavenaghweb@hotmail.com)