• Resolved inaka

    (@inaka)


    Hi Joe,

    A few years ago I asked about how to display auction listings in a random order, and you provided a JavaScript demo that worked perfectly for me.

    Unfortunately, I updated my site, and most the javascript, and that demo link you originally provided is now a dead link.

    Could you please repost the javascript solution for displaying listings in a random order?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Joe

    (@morehawes)

    Hi @inaka,

    Thanks for reaching out. I have put together a quick solution for you here. The pertinent code:

    <script>
    function auction_nudge_loaded() {
    // Get the container element
    const container = jQuery(".an-item-wrap");

    // Get the items
    const items = container.find(".an-item");

    // Remove
    items.each(function () {
    const item = jQuery(this);
    item.remove();
    });

    // Shuffle
    items.sort(function () {
    return 0.5 - Math.random();
    });

    // Re-add
    container.append(items);
    }
    </script>

    I hope this helps.

    Joe

    Thread Starter inaka

    (@inaka)

    Hi Joe,

    That worked like a charm again.

    Thank you again! This time I saved the javascript. ??

    Plugin Author Joe

    (@morehawes)

    Hi @inaka,

    Glad to hear ??

    Joe

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Random Order Display’ is closed to new replies.