Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

History.js Adapter has already been loaded... #59

Open
Phifo opened this issue Jan 14, 2014 · 10 comments
Open

History.js Adapter has already been loaded... #59

Phifo opened this issue Jan 14, 2014 · 10 comments

Comments

@Phifo
Copy link

Phifo commented Jan 14, 2014

I'm getting this error in the console. I thought I was using another javascript plugin in my project that include the history.js before wiselinks, but I created a fresh new rails application and just add jquery and wiselinks and still getting this error.

@igor-alexandrov
Copy link
Owner

This means that your javascripts are reloaded during request to your application. Please add some additional info:

  1. How do you initialiaze Wiselinks?
  2. What layouts are you using?

@Phifo
Copy link
Author

Phifo commented Jan 14, 2014

as I said now I'm trying a very basic installation, I initialized wiselinks as the readme says.

I noticed I get this error just in development mode, I tried in production mode and I got no error.

In development mode I checked the requests and I noticed that it is loading the native.history.js and the wiselinks.js, these files are the same as I can see.

edit: well, the files are not the same but are similar, and maybe those files are loading history two times?

@igor-alexandrov
Copy link
Owner

Are you using Wiselinks as a gem, or you downloaded standalone js version?

@igor-alexandrov
Copy link
Owner

Basically you should not require native.history.js when you require wiselinks.js, because it already requires history.js.

@Phifo
Copy link
Author

Phifo commented Jan 14, 2014

Sorry, I forgot to say I'm using wiselinks as a gem and added to my application.js with the //= require wiselinks after jquery. Here is where I get the error and the native.history.js and wiselinks.js both are loading (_form, _link and the others are loaded too, before the wiselinks.js, I don't know why this happen). As I said this only happen in development mode and I didn't touch any development or application configuration file.

Meanwhile I'm using the standalone version without any problem.

@aishek
Copy link
Contributor

aishek commented Jan 31, 2014

I'm having same issue in following scenario: request some page, which comes with cache header (Last-Modified and ETag), when request same page with wiselinks. In this case, wiselinks received full page source from browser (because it was cached like this), not only content part. Full page source contains scripts, which browser loads and you get topic error because of second time loading of wiselinks javascript (it contains History.js).

@aishek
Copy link
Contributor

aishek commented Jan 31, 2014

@Phifo please check if #62 fixes your issue

@PikachuEXE
Copy link

#62 Merged

@PikachuEXE
Copy link

Also this is more like a bug of History.js instead of wiselinks
Search with this link: https://github.com/browserstate/history.js/search?q=has+already+been+loaded&type=Issues

@aolko
Copy link

aolko commented May 15, 2017

default example leads to that error:

(function() {
    $(document).ready(function() {
        window.wiselinks = new Wiselinks($('main'));
        $(document).off('page:loading').on('page:loading', function(event, $target, render, url) {
            return console.log("Loading: " + url + " to " + $target.selector + " within '" + render + "'");
        });
        $(document).off('page:redirected').on('page:redirected', function(event, $target, render, url) {
            return console.log("Redirected to: " + url);
        });
        $(document).off('page:always').on('page:always', function(event, xhr, settings) {
            return console.log("Wiselinks page loading completed");
        });
        $(document).off('page:done').on('page:done', function(event, $target, status, url, data) {
            return console.log("Wiselinks status: '" + status + "'");
        });
        return $(document).off('page:fail').on('page:fail', function(event, $target, status, url, error, code) {
            return console.log("Wiselinks status: '" + status + "'");
        });
    });

}).call(this);

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

5 participants