AJAX content
-
With the previous version (1.2, I believe) I had been using:
createJSJGallerySlideshow();
for displaying galleries in content loaded via AJAX.This doesn’t seem to be working for me since upgrading to 2.0. Do you have any suggestions?
Thank you for the plugin!
-
Hi DDDDvvVVV,
Sorry for the delay, I’ve been super busy on other stuff latelty.
This is a weird bug. I spent a lot of time architecturing this thing so that it would be backwards compatible. Can you go to Settings > JSJ Gallery Slideshow > Advanced > Log and then turn logging on.
After you do that 1. go to your site, 2. open your console, 3. and run the function
window. createJSJGallerySlideshow()manually and copy paste the output here.Here’s what I got on mine:
automatically find and run slideshows jsj-gallery-slideshow.min.js:514
[cycle2] –c2 init– jsj-gallery-slideshow.min.js:410
[cycle2] cycle-stopped jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] cycle-stopped jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] cycle-destroyed jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] –c2 init– jsj-gallery-slideshow.min.js?ver=3.9.2:410
window.createJSJGallerySlideshow();
[cycle2] cycle-stopped jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] cycle-stopped jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] cycle-destroyed jsj-gallery-slideshow.min.js?ver=3.9.2:410
[cycle2] –c2 init– jsj-gallery-slideshow.min.js?ver=3.9.2:410
Object {init: function, getJQueryElement: function, get$el: function, settings: Object, utilities: Object…}Also, can you include a URL for this? That would help in debugging it. Thanks!
Hi Jorge! No problem, thanks for the help.
Here is a link to the page:
http://bit.ly/1yHDNJRWhen I run the function on the page with the ajax content loaded:
[Log] automatically find and run slideshows (jsj-gallery-slideshow.min.js, line 514)
> window.createJSJGallerySlideshow();
< ObjectAlthough, when I go to the post (opened in new tab), it works as expected:
[Log] automatically find and run slideshows (jsj-gallery-slideshow.min.js, line 514)
[Log] [cycle2] –c2 init– (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] cycle-stopped (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] cycle-stopped (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] cycle-destroyed (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] –c2 init– (jsj-gallery-slideshow.min.js, line 410)
> window.createJSJGallerySlideshow();
[Log] [cycle2] cycle-stopped (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] cycle-stopped (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] cycle-destroyed (jsj-gallery-slideshow.min.js, line 410)
[Log] [cycle2] –c2 init– (jsj-gallery-slideshow.min.js, line 410)
< ObjectOn a related note, I discovered I can get the gallery to work when I load ‘jsj-gallery-slideshow.min.js’ again alongside the ajax content. I’m not sure why that makes it work since it’s already loaded.
Hi DDDDvvVVV,
I know what’s happening! This is definitely a BUG!
Basically, the plugin is caching the jQuery element. So it only looks for the slideshows on
document.ready. When it loads new content through AJAX it’s still using the same jQuery elements and is not querying the DOM for new ones. This is a bug, since when you run the slideshow it should query new jQuery elements.Anyways, I’m going to work on this plugin for a bit this week. I’ll fix it in a couple of days and let you know. The next update should fix this.
If you want to fix it yourself, you might need to setup grunt and stuff like that, but basically the fix is this:
https://github.com/thejsj/jsj-gallery-slideshow/blob/master/static/js/app/main.js#L105-L110
Change this:
self.getJQueryElement = function () { if (__self.document_ready) { return __self.$el; } return $(__self.selector); };for this:
self.getJQueryElement = function () { return $(__self.selector); };I will probably make it so that if you do
createJSJGallerySlideshow(true)it will requery the DOM for slideshow elements, so you might want to include that in your code.Thanks for the find!
Thanks for the update, glad you were able to find what was happening. I may wait for the next update, since I’m not set up with Grunt or anything like that. It’s something I’ll check out in the meantime though. Thank you for your help!
Sounds good! Let me see when I can tackle that. Didn’t have time in the last couple of days.
This should be in for version 2.0.2. Give it a try and let me know if it worked for you!
Wooo! The new update is working great. Thanks Jorge!
The topic ‘AJAX content’ is closed to new replies.