New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flip toggle switch with change event bound, triggers multiple times #2315

Closed
vpxavier opened this Issue Aug 20, 2011 · 5 comments

Comments

Projects
None yet
4 participants
@vpxavier

vpxavier commented Aug 20, 2011

Hello in this jsFiddle: http://jsfiddle.net/vpxavier/K7puf/
if you go to "page1", you will see that the change event is triggered multiple times when you click to change the switch's value.

Tested on Android with JQM beta 2

@vpxavier

This comment has been minimized.

Show comment
Hide comment
@vpxavier

vpxavier Aug 23, 2011

Also tested on google chrome

vpxavier commented Aug 23, 2011

Also tested on google chrome

@vpxavier

This comment has been minimized.

Show comment
Hide comment
@vpxavier

vpxavier Aug 27, 2011

Still occurs with today's latest build

vpxavier commented Aug 27, 2011

Still occurs with today's latest build

@ghost ghost assigned gseguin Sep 5, 2011

@dannyc

This comment has been minimized.

Show comment
Hide comment
@dannyc

dannyc Sep 5, 2011

Contributor

Three additional details:

  • Multiple events only fires when you click on the slider "cover". If however you click on the work "off" or "on" only one event fires.
  • The values being returned at the change event are inconsistent. For example http://jsfiddle.net/p5QCZ/ forked from above I added the val() being returned at each bind event. The first event firing returns value before the click, and the second the desired value.
  • Click and hold sliding with the mouse fires an uncountable number of events.
Contributor

dannyc commented Sep 5, 2011

Three additional details:

  • Multiple events only fires when you click on the slider "cover". If however you click on the work "off" or "on" only one event fires.
  • The values being returned at the change event are inconsistent. For example http://jsfiddle.net/p5QCZ/ forked from above I added the val() being returned at each bind event. The first event firing returns value before the click, and the second the desired value.
  • Click and hold sliding with the mouse fires an uncountable number of events.

@ghost ghost assigned jblas Sep 22, 2011

@jblas

This comment has been minimized.

Show comment
Hide comment
@jblas

jblas Sep 22, 2011

Contributor

This is happening because refresh() is called from both vmousedown and vmouseup with the same signature that allows it to go into the are of code that updates the control's value and dispatches the "change" event. For some reason this code does NOT check to see if the value actually did change before triggering the change event.

I have a fix for this. I'll check it in after I finish the unit test case for it.

Contributor

jblas commented Sep 22, 2011

This is happening because refresh() is called from both vmousedown and vmouseup with the same signature that allows it to go into the are of code that updates the control's value and dispatches the "change" event. For some reason this code does NOT check to see if the value actually did change before triggering the change event.

I have a fix for this. I'll check it in after I finish the unit test case for it.

@jblas

This comment has been minimized.

Show comment
Hide comment
@jblas

jblas Sep 22, 2011

Contributor

Landed the fix on the HEAD:

4fa6ccd

Contributor

jblas commented Sep 22, 2011

Landed the fix on the HEAD:

4fa6ccd

@jblas jblas closed this Sep 22, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment