Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Callbacks only apply to first of original selector #4

Closed
nesl247 opened this issue Jan 8, 2014 · 5 comments
Closed

Callbacks only apply to first of original selector #4

nesl247 opened this issue Jan 8, 2014 · 5 comments

Comments

@nesl247
Copy link

nesl247 commented Jan 8, 2014

If you use

$('input[type=date]').pickmeup();

all the callbacks get applied to the first selector match. While I'm not sure the following change doesn't have any other affects, changing

options[i] = options[i].bind(this); to $this.bind(options[i]); on https://github.com/nazar-pc/PickMeUp/blob/master/js/jquery.pickmeup.js#L718 fixes it.

This is because you aren't binding the callbacks to the selector, so this always refers to the first matched selector.

@nazar-pc
Copy link
Owner

nazar-pc commented Jan 8, 2014

Can you provide example on jsfiddle?

@nesl247
Copy link
Author

nesl247 commented Jan 8, 2014

This is the broken version http://jsfiddle.net/6TDF7/3/

I'm actually testing my fix, and for some reason it worked in IE, but doesn't want to work in Chrome.

@nesl247
Copy link
Author

nesl247 commented Jan 8, 2014

I've updated the original comment with the proper fix. Need to replace the line I mentioned with $this.bind(options[i]);.

Working: http://jsfiddle.net/jQbYH/3/

@nazar-pc
Copy link
Owner

nazar-pc commented Jan 8, 2014

Please, try latest Git version 2.2.1, it should work correctly.

@nesl247
Copy link
Author

nesl247 commented Jan 9, 2014

It appears to be working perfectly now.

@nazar-pc nazar-pc closed this as completed Jan 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants