The `$()` function is a shortcut for `$(document).ready()`, and we were attaching events to `$(document).ready()` inside the `$()` function. In a similar way, we were handling the `page:load` and `ajax:complete` events inside the `$()` function. But when those events trigger, the DOM is already ready. Besides, we don't have to wait for the DOM to be ready before attaching events to the `document` element. Quoting jQuery's `.on()` documentation: > The document element is available in the head of the document before > loading any other HTML, so it is safe to attach events there without > waiting for the document to be ready. Co-Authored-By: Senén Rodero Rodríguez <senenrodero@gmail.com>
15 lines
317 B
JavaScript
15 lines
317 B
JavaScript
//= require d3
|
|
//= require c3
|
|
//= require c3ext
|
|
//= require stats
|
|
|
|
var initialize_stats_modules = function() {
|
|
"use strict";
|
|
|
|
App.Stats.initialize();
|
|
};
|
|
|
|
$(document).ready(initialize_stats_modules);
|
|
$(document).on("page:load", initialize_stats_modules);
|
|
$(document).on("ajax:complete", initialize_stats_modules);
|