mercredi 28 juin 2017

VITAL NEED: EmberJS equivalent of jQuery's .ready() function that STAYS ON

Ok. So the reason why I am labeling this as a vital need is because I have written another question like this in the past, and I gave when I was asked to give a specific thing that I was trying to accomplish, and the whole thing became about that, and nothing got solved.

Now I have come to like 5 different things I wanted to accomplish that I would've been able to accomplish with jQuery and .ready() and have ALL the functionality done in a half hour. I have spent 3 days searching Google, reading the official Ember 2.13.0 docs, etc. to no avail.

This HAS to exist, because I simply refuse to believe that I can't put an event listener that will ALWAYS run on the route regardless of transitioning to child routes or clicking things or the fact that it already rendered and doesn't render twice. The only one I've been able to get to work is didRender on the component. Nothing else works.

I tried willTransition on the route. Does not work. I've tried didTransition on the route. Does not work. I've searched Google only to come up with answers on here for Ember 1x.

All I want to do is have something like this:

Ember.$('input,select,textarea').on('change',function() {
    do stuff here
}

That will:

  • Work when the route is entered
  • Still continue to function when a user clicks on sub-routes*
  • Not stop working EVER unless the user exits the actual parent route completely and goes somewhere else
  • Run all the time

What didRender on the component does is that while it's on the opening route (android/setup) .. it will actually work.. until I click a different tab that goes to a different sub route. Then it stops working and upon returning to the original sub route it starts on, it still won't work.

I don't know if it's because the component doesn't get rendered again or what but why it stops working and the event listener dies is beyond me.

If you want to know why I want to do this, I can give you 5 reasons right off the bat, so I would rather the actual EXACT PROGRAMMATIC FUNCTION I'm asking for how to do be explained instead of a single task or goal in terms of functionality because I have needed this SO MANY TIMES and have had to go around my butt to get to my elbow because I can't just .ready it and call it a day.




Aucun commentaire:

Enregistrer un commentaire