Answer the question
In order to leave comments, you need to log in
How to make proper shuffle collection in backbone?
First, I unload the models from the server into the collection and render. Then, according to the DOM event, it is necessary to mix the models in the collection and draw again, instead of the previous ones.
I googled this code on the internet:
AppCollection.on("add" , onUpdateItem );
$( document ).bind("keyup", function(e){
if( e.keyCode === 13 ) {
var shuffledCopy = AppCollection.clone().shuffle();
$("body").html("");
AppCollection.reset().add( shuffledCopy );
}
})
Answer the question
In order to leave comments, you need to log in
Do you really need to shuffle the collection? Maybe it's enough to bring it out in a mixed form?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question