Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Activate Sort function on load - Shuffle.js

As the title says, how can I active the sort by 'data-title' on load? I tried to active it in the HTML but it didn't work. I'm no Javascript expert but my gut tells me this is easy - sadly I cant figure it out.

https://vestride.github.io/Shuffle/

emo.prototype._handleSortChange = function (evt) {
// Add and remove `active` class from buttons.
var wrapper = evt.currentTarget;
var buttons = Array.from(evt.currentTarget.children);
buttons.forEach(function (button) {
    if (button.querySelector("input").value === evt.target.value) {
        button.classList.add("active");
    } else {
        button.classList.remove("active");
    }
});

// Create the sort options to give to Shuffle.
var value = evt.target.value;
var options = {};

function sortByDate(element) {
    return element.getAttribute("data-title");
}

function sortByTitle(element) {
    return element.getAttribute("data-title").toLowerCase();
}

if (value === "date-created") {
    options = {
        reverse: true,
        by: sortByDate,
    };
} else if (value === "title") {
    options = {
        by: sortByTitle,
    };
}

this.shuffle.sort(options);

};

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!