Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
December 18, 2019 at 9:33 pm #1167519
Hi there,
I found an old thread with some JS modifications to randomize testimonials upon page load, but it doesn’t seem to be working. The testimonials continue to display in the same order that they were loaded.
Can you see if this code is still valid and diagnose what I may be doing wrong, please?
This is my JS code, which I modified enfold/config-templatebuilder/avia-shortcodes/testimonials/testimonials.js:
(function($) { "use strict"; // ------------------------------------------------------------------------------------------- // testimonial shortcode javascript // ------------------------------------------------------------------------------------------- $.fn.shuffle = function() { var allElems = this.get(), getRandom = function(max) { return Math.floor(Math.random() * max); }, shuffled = $.map(allElems, function(){ var random = getRandom(allElems.length), randEl = $(allElems[random]).clone(true)[0]; allElems.splice(random, 1); return randEl; }); this.each(function(i){ $(this).replaceWith($(shuffled[i])); }); return $(shuffled); }; $.fn.avia_sc_testimonial = function(options) { return this.each(function() { var container = $(this), elements = container.find('.avia-testimonial'); $('.avia-testimonial').shuffle(); //trigger displaying of thumbnails container.on('avia_start_animation', function() { elements.each(function(i) { var element = $(this); setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150)); }); }); }); } }(jQuery));December 18, 2019 at 10:24 pm #1167529Hi all,
Looks like this is working now. Feel free to close the thread. Thank you!
December 19, 2019 at 6:58 am #1167633Hi,
If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- The topic ‘Randomize testimonials’ is closed to new replies.
