Skip to content

Commit

Permalink
No need to check for Turbolinks defined.
Browse files Browse the repository at this point in the history
If there's no Turbolinks, we registered an event handler
for an event that will never be hired -- this should not harm
anything.

But the check introduces possible order-of-load errors, where
blacklight core accidentally ends up loaded before turbolinks,
so doesn't set up the event handler, but then turbolinks loads later,
so the event handler was needed, but didn't load. ran into this
with an engine that inserted it's 'require x.js' before turbolinks.
Best to avoid order-of-load dependencies if we can; we can.
  • Loading branch information
jrochkind committed Feb 11, 2014
1 parent ac434f2 commit f700ae6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/assets/javascripts/blacklight/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Blacklight = function() {
}
}();

if (typeof Turbolinks !== "undefined") {
$(document).on('page:load', function() {
Blacklight.activate();
});
}
// turbolinks triggers page:load events on page transition
// If app isn't using turbolinks, this event will never be triggered, no prob.
$(document).on('page:load', function() {
Blacklight.activate();
});

$(document).ready(function() {
Blacklight.activate();
});
Expand Down

0 comments on commit f700ae6

Please sign in to comment.