Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
11–18 of 18 posts
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#12When handling options, I quite like this pattern: var settings = $.extend({ dragable: true, clickable: true, ontext: 'ON', offtext: 'OFF', on: true, animtime: 300 }, opts); The $.extend method still returns a suitable object even if `opts` is undefined. You also might want to `return this.each` so calls can be chained. All of this is covered here: http://docs.jquery.com/Plugins/Authoring
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#13I like these, but how do you get the "value"? Im not a javascript guru, but is there an attribute or value I need to check?
It looks like the primary function of the button is to alter something on the page via the toggles function, but I guess you could check if it had the active class or not.
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#14This looks great! One minor suggestion: make the toggle button non selectable for dragging. http://jsfiddle.net/SWqw3/ show's a basic way of doing this.
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#15nice work! what license is this released under?
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#16Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#17Check it out here: http://taitems.github.com/UX-Lab/ToggleSwitch/index.html
I also investigated achieving something similar using only CSS base on a :checkbox, but the browser support, even in "modern" browsers was poor: http://taitems.github.com/UX-Lab/CSSInputs/index.html
Thoughts and hacks on the above, here: http://taitems.tumblr.com/post/23099016111/css3-input-stylin...
Re: Show HN: Easily Customizable Toggle Buttons - jQuery Plugin
#18Earlier quoted context omitted.
It looks like the primary function of the button is to alter something on the page via the toggles function, but I guess you could check if it had the active class or not.
You can either check the class of the .slide div or have it linked to a checkbox which will be checked or unchecked.
Thanks for this simon!