Question

I'm using Yepnope to load external javascript. In this case, directives and controllers for an angularjs based app. The problem I'm facing is that the callback function does not fire all the time and the complete function usually fires one and rarely more than twice.

I thought I could fix this by counting the number of callbacks and calling my callback function when the last one is called by using _.after([no of scripts], myFn) but that appears to not work all the time as well.

Also, I had to use setTimeout on some of the calls before they worked.

Finally, if the library is loaded, it appears the callback does not fire.

What I'm looking for is a function that will be called whenever I make a call to yepnope irrespective of what happens. I thought the complete function was for that but I appears I was wrong.

Is there any such function?

If no, how do I get this behaviour?

Eg

yepnope({ test: window.v1,  complete: function(){...}, callback:...});
ypenope({ test: window.v2,  complete: function(){...}, callback:...});
yepnope([ {test: window.v1, complete: function(){...}, callback:...} ]);

How do I get complete to fire 3 times in the case above?

Was it helpful?

Solution

Solved the problem by creating a small wrapper around yepnope. I'm making the calls to yepnope through that wrapper so I'm able to track each call and fire the complete function as and when needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top