Skip to content
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

support selector in 'on' function #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

support selector in 'on' function #20

wants to merge 4 commits into from

Conversation

liady
Copy link

@liady liady commented Apr 27, 2015

Support selector passing in "on" function (optional).
If passed, the handler first checks the event target to match the selector.

@sqal
Copy link

sqal commented Apr 28, 2015

This is not working as it should, Check out demo: http://jsfiddle.net/q8grdnxa/

It should detect if user clicks on any element within delegated element.

@liady
Copy link
Author

liady commented Apr 28, 2015

Thanks. Changed to a limited "closest" check:
http://jsfiddle.net/q8grdnxa/1/

@sqal
Copy link

sqal commented Apr 28, 2015

👍 Thank you @liady

@sqal
Copy link

sqal commented Apr 30, 2015

I just noticed that $(document).ready event doesn't fire after your changes @liady Can you check what is wrong?

Worse, can't attach single event to element without additional selector parameter

// .on(events, handler)
if (handler) {
if(selector){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be check if selector is a string, because if user do not pass selector it becomes a handler function which evaluates to true ofc :)

@liady
Copy link
Author

liady commented Apr 30, 2015

You're right, I already handled that case but didn't clear the selector variable. Fixed now:
http://jsfiddle.net/q8grdnxa/2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants