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

Problem while trying to attach event handlers #10

Open
dortheimer opened this issue Jan 6, 2014 · 1 comment
Open

Problem while trying to attach event handlers #10

dortheimer opened this issue Jan 6, 2014 · 1 comment

Comments

@dortheimer
Copy link

When trying to apply custom event handlers, sometimes the html isn't ready and they aren't attached.

$('.rating-input').on('mouseenter', 'i', function () {
 // do some cool stuff
});

This happens due to the asynchronous nature of the execution on the code.
I think that the best way to fix it is to add some custom events to the library like:
[ ] Ready - After html rendered
[ ] Mouse over
[ ] Mouse out
[ ] Mouse click

I can add there handlers if my changes are accepted..

@javiertoledo
Copy link
Owner

It sounds like an awesome idea! Meanwhile you could do something like this to workaround the problem:

HTML:

<div class="rating-input-wrapper">
    <input type="number" name="your_awesome_parameter" id="some_id" class="rating" />
</div>

JS:

$('.rating-input-wrapper').on('mouseenter', '.rating-input span', function () {
  // do some cool stuff
});

Also note that in the last version of this plugin, i elements were replaced by span elements in order to follow the bootstrap 3 conventions.

@javiertoledo javiertoledo self-assigned this May 25, 2015
@javiertoledo javiertoledo removed their assignment May 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants