Exception from Tracker afterFlush function: undefined

Hey, I can’t figure this one out.

I’m loading my images with a lightbox package and I get this error when I go to my page with a link:

Exception from Tracker afterFlush function: undefined
meteor.js:864 TypeError: $(...).magnificPopup is not a function
    at Template.producten.rendered (http://localhost:3000/app/client/views/frontpage/frontpage.coffee.js?033c6aeb3cbc8e04f9d16026640e11a71fa279e3:43:25)
    at http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:3338:22
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:3679:12)
    at fireCallbacks (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:3334:12)
    at null.<anonymous> (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:3427:5)
    at http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:1788:14
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:2219:12)
    at http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:1787:15
    at Object.Tracker._runFlush (http://localhost:3000/packages/tracker.js?16c53d4f91467c6a41bbb860bf6c48f871710022:531:11)
    at onGlobalMessage (http://localhost:3000/packages/meteor.js?637cc835a2ee4a2302a010c9a4c97b906db5f41c:373:23) undefined

But it doesn’t happen when I refresh the page manually. The route has nothing special. The page only has static content.

The only thing I notice is that the DOM object looks like this when manually refreshing:

[div.row.lightbox-parent, prevObject: jQuery.fn.init[1], context: document, selector: “.lightbox-parent”]

and it looks like this when I’m just using my router links:

[div.row.lightbox-parent, prevObject: m.fn.init[1], context: document, selector: ".lightbox-parent"]

Notice the jQuery.fn and m.fn

What’s going on?

I am having the exact same problem with Materialize modals. I am also using a helper with an onRendered method:

`Template.classrooms.onRendered(function () {



It works fine if I reload the page but once I navigate and come back, I get a:

“Exception from Tracker afterFlush function:”

“TypeError: $(…).leanModal is not a function”

Did you manage to figure this out?

Hi CodeSelector, I figured out what the root of my bug was. You can check out my full bug report and response here:


Essentially, I was initializing jQuery twice. Hope this works for you!

1 Like

I came to the same solution. I had a jquery CDN link somewhere in the bottom of a page.

Thanks for posting your solution, hopefully it will help others too.