Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Inconsistent behavior #34

Open
romanbsd opened this issue Dec 22, 2013 · 0 comments
Open

Inconsistent behavior #34

romanbsd opened this issue Dec 22, 2013 · 0 comments

Comments

@romanbsd
Copy link

There's currently inconsistency in the "isReady" / not states.
Consider this part of (the compiled javascript):

      if ($.turbo.isReady) {
        return callback($);
      } else {
        return $document.on('turbo:ready', function() {
          return callback($);
        });
      }

When it's ready, then the callback is executed only once (right away), and if it's not, then the callback is added on 'turbo:ready' for ever. I propose to change the "on()" to "one()" for consistency.

P.S. I found that while doing performance analysis of our application, and found multiple invocations of the "onready" callback.

neilsarkar added a commit to neilsarkar/jquery.turbolinks that referenced this issue Jul 24, 2014
See kossnocorp#34

When loading scripts asynchronously, we noticed inconsistent behavior where the initial page load fired all of our handlers, but subsequent Turbolinks page loads did not fire any handlers.

This fix calls the callback immediately if the DOM is ready and binds to the page load event for subsequent Turbolinks page loads.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant