Open Phifo opened 10 years ago
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?
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?
Are you using Wiselinks as a gem, or you downloaded standalone js version?
Basically you should not require native.history.js when you require wiselinks.js, because it already requires history.js.
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.
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).
@Phifo please check if https://github.com/igor-alexandrov/wiselinks/pull/62 fixes your issue
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
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);
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.