Last active
January 20, 2017 13:24
-
-
Save paoga87/a6a26fa82901603cec00f20986e40557 to your computer and use it in GitHub Desktop.
After having a list of buttons with event dates/names, with the date formatted as string, I decided to re-format the date (after fetching the elements via MySQL/PHP) like this: dd/mm/yyyy, and added each to the individual buttons as IDs. Then do the sorting straight from jQuery. (Querying the MySQL with PHP back-end was not an option because the…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Functionality to sort the event buttons by date using jQuery | |
var $results = $('.mainDivClass'); //This could be an id as well | |
var $itemBtn = $results.children('.individualItemClass'); //This could be an id as well | |
$itemBtn.detach(); | |
$itemBtn.sort(function(a,b){ | |
return a.id > b.id; | |
}); | |
$itemBtn.appendTo($results); | |
// -- End of Functionality to sort the event buttons by date --// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment