Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda