wiselinks icon indicating copy to clipboard operation
wiselinks copied to clipboard

History.js Adapter has already been loaded...

Open Phifo opened this issue 11 years ago • 10 comments

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.

Phifo avatar Jan 14 '14 09:01 Phifo

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?

igor-alexandrov avatar Jan 14 '14 09:01 igor-alexandrov

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?

Phifo avatar Jan 14 '14 09:01 Phifo

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

igor-alexandrov avatar Jan 14 '14 18:01 igor-alexandrov

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

igor-alexandrov avatar Jan 14 '14 18:01 igor-alexandrov

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.

Phifo avatar Jan 14 '14 20:01 Phifo

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 avatar Jan 31 '14 08:01 aishek

@Phifo please check if https://github.com/igor-alexandrov/wiselinks/pull/62 fixes your issue

aishek avatar Jan 31 '14 20:01 aishek

#62 Merged

PikachuEXE avatar Mar 17 '14 09:03 PikachuEXE

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

PikachuEXE avatar Mar 18 '14 03:03 PikachuEXE

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);

aolko avatar May 15 '17 12:05 aolko