Bttstrp / bootstrap-switch

Turn checkboxes and radio buttons in toggle switches.
MIT License
5.09k stars 1.45k forks source link

the switch will only slide and not switch on click! #69

Closed neuropass closed 11 years ago

neuropass commented 11 years ago

Hi,

I have a problem and I'm not sure I'm missing something.. the switch will only slide if I click and slide with the mouse. it will not switch on click.. any idea? 0_o

Thanks in advance

GnickIS commented 11 years ago

My switches will sporadically work. When I refresh the page sometimes it will be fully function other times It won't switch when clicked. I can still get it to switch if I click the white center segment repeatedly, but only the white center segment. If I click on the on/off segments nothing happens at all.

technobly commented 11 years ago

If you comment out this code, it will ignore the dragging feature: https://github.com/nostalgiaz/bootstrap-switch/blob/master/static/js/bootstrapSwitch.js#L148-L163

Many times when you click, your hand jerks a bit and you end up dragging too... so you wind up in a partially dragged state that corrects itself when you mouseout. But... it's just too inconsistent, so it's better to just make it clickable in my opinion.

Once you do that though, you will inevitably try to click a bunch of sliders fast to toggle them and you'll notice sometimes it doesn't register the click. What's happening is you are click-dragging off the button on the way to the next one and that first one gets a mouseout event that prevents it from toggling. I'm thinking maybe ignoring that mouseout might help, but then again... it kinda doesn't. Seems like sometimes also clicks just aren't seen. It wouldn't be a problem if I didn't have this: http://proto.io/freebies/onoff/ to compare it to... and the proto.io slider works fast every time. Only problem with proto.io is there are no JS hooks in it.. just CSS.