This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 8 - Pages: 1 - Last Post: 15-Dec-2014 05:38 Last Post By: Mike-West
Mike-West

Posts: 13
Registered: 30-Dec-2010
window.onhashchange event
Posted: 12-Dec-2014 09:05
 
  Click to reply to this thread Reply
I have been trying out the Fully skin and came across a problem - when I click on a thumbnail, it should change the main image to correspond with it. This happens when testing locally on my computer, but does not work when on a server.

I traced the problem to the code where the location.hash is changed in the onThumbClick function. The window.onhashchange function that is set in the initSkin function in main.js which is supposed to handle this event has been overridden by some hidden code in the widget container. Specifically it is set to:
hash change setfunction() {
     _ja_W.Reload();
     delayedVibrantAdReload();
}

Just for testing I deleted the code at the end of index.html that gets added magically by the Make album process, and hey presto, it works as it should.

I am not using any widgets, so why does the widget container code get added? How can I get round this problem? Thanks for your help.

Edited by: Mike-West on 12-Dec-2014 09:06
jGromit

Posts: 7,468
Registered: 31-Jan-2006
Re: window.onhashchange event
Posted: 12-Dec-2014 13:13   in response to: Mike-West in response to: Mike-West
 
  Click to reply to this thread Reply
I'll have to leave it to someone else to address the conflict between the widget code and the Fully code.

But to eliminate the jAlbum widgets entirely, go to Album > Settings > Advanced > Metadata, and uncheck Include jAlbum widget support.
Mike-West

Posts: 13
Registered: 30-Dec-2010
Re: window.onhashchange event
Posted: 12-Dec-2014 19:27   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Thanks for the reply. The checkbox for Include jAlbum widget support is greyed out. Perhaps because I'm using a trial version?

I did find a solution though, in case anyone else is looking:-

In main.js (in the skin's res directory) replace the line
window.onhashchange = function() {

with
$(window).on("hashchange", function () {


As I understand it, this will listen to the hashchange event along with any other listeners, as opposed to setting the only function that should be called onhashchange.

I would like confirmation that this is appropriate. And why doesn't the code in the widget container do likewise - and play nice?
jGromit

Posts: 7,468
Registered: 31-Jan-2006
Re: window.onhashchange event
Posted: 12-Dec-2014 21:49   in response to: Mike-West in response to: Mike-West
 
  Click to reply to this thread Reply
Mike-West wrote:
The checkbox for Include jAlbum widget support is greyed out. Perhaps because I'm using a trial version?

Yes, exactly.
Mike-West

Posts: 13
Registered: 30-Dec-2010
Re: window.onhashchange event
Posted: 14-Dec-2014 00:54   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I now have a license and I can confirm that using the standard Fully skin without widget support, having uploaded the album to a server, clicking on a thumbnail does change the main picture as intended.

With widget support enabled, clicking on a thumbnail does not change the main picture. However, this only happens on the second and subsequent visits to a page.

This behavior can be seen on the baseball album, the link for which was given in the current newsletter. http://gerardspaans.jalbum.net/APPM%20Rabbits/Junioren%20seizoen%202014/Rabbits%20vs%20Bixie%2006%20sept/index.html#_I0G7335
jGromit

Posts: 7,468
Registered: 31-Jan-2006
Re: window.onhashchange event
Posted: 14-Dec-2014 01:09   in response to: Mike-West in response to: Mike-West
 
  Click to reply to this thread Reply
I've tested with all browsers, and the problem seems to be confined to IE11.

No problem with thumbnail clicking in Chrome on WIn7 or OSX, Firefox on Win7 or OSX, or Safari on OSX.
Mike-West

Posts: 13
Registered: 30-Dec-2010
Re: window.onhashchange event
Posted: 14-Dec-2014 06:24   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Agreed as far as I was using IE11 on Win7 where I see the problem and just tried on Chrome where it works as expected. Also, tried Safari on a mac and it worked as expected.
jGromit

Posts: 7,468
Registered: 31-Jan-2006
Re: window.onhashchange event
Posted: 14-Dec-2014 06:35   in response to: Mike-West in response to: Mike-West
 
  Click to reply to this thread Reply
It's a caching problem. I've seen IE do things like this before - in trying to be "efficient," it caches things it shouldn't. In this case, the problem appears to clear up if you simply force a reload by hitting F5.
Mike-West

Posts: 13
Registered: 30-Dec-2010
Re: window.onhashchange event
Posted: 15-Dec-2014 05:38   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Pressing F5 to force a page reload restarts the skin's script and resets the onhashchange handler so that the click event works again. But if you click on another folder and back, then thumbnail clicking stops working again. Whether the page reloads from the cache or the server would do the same.

I can set a breakpoint in the script using the debugger at the point when the click event takes place and can see the onhashchange handler has been reassigned from what the skin's author intended, as I first pointed out.

What I can't see is the code in the widget container because that gets loaded by an unconventional means and in any case I don't think I should be trying to debug that. But it obviously interferes with the skin's script.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums