NoSleep.js icon indicating copy to clipboard operation
NoSleep.js copied to clipboard

Not compatiable with jQuery handler function

Open benopotamus opened this issue 6 years ago • 1 comments

Documentation Is:

  • [ ] Missing
  • [ ] Needed
  • [ ] Confusing
  • [x ] Not Sure?

Please Explain in Detail...

Howdy! I think NoSleep.js doesn't work with with a jQuery click event when a handler reference is used rather than an anonymous function (I hope I got those terms right :-P ).

E.g.

Doesn't work (NoSleep.enable() is in the start_ex_wizard function) $('#start-link').click(start_ex_wizard);

Does work $('#start-link').click(function(){ NoSleep.enable(); // Prevent device from sleeping start_ex_wizard(); });

Your Proposal for Changes

I thought you might like to add a note to the readme.md so others are aware. Alternatively I could document it on StackOverflow.

benopotamus avatar Jan 06 '19 11:01 benopotamus

Not sure if it is related, but I am trying to use it with AngularJS and I cannot make it work. I added it in an ng-click controller function and as soon as noSleep.enable() is called, the CPU goes up to 170%. The angular event handler also uses jquery that's why I thought it might be a similar case.

pmiklos avatar Feb 06 '19 06:02 pmiklos