Created
November 25, 2014 15:28
-
-
Save dacur/253ea91cbf93e9125f54 to your computer and use it in GitHub Desktop.
Creating a header for each month when listing out data by date (descending order). Month header only prints once per month.
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
| function BuildCompletedJournals(data){ | |
| var i = 0; | |
| var html = ''; | |
| var exists; | |
| var month = ''; | |
| var journal; | |
| var date = ''; | |
| var months = []; | |
| for(i=0; i<data.length; i++){ | |
| journal = data[i]; | |
| date = moment(journal.JournalDate).format("MMM Do YYYY"); | |
| month = moment(journal.JournalDate).format("MMMM"); | |
| if(months.indexOf(month)==-1){ | |
| months.push(month); | |
| html += '<h1 class="month">' + month + '</h1>'; | |
| } | |
| html += '<div class="journalRow" id="' + journal.ID + '">'; | |
| html += '<div class="journalName font700">' + journal.Title + '</div>'; | |
| html += '<div class="journalDate">' + date + '</div>'; | |
| html += '<div class="journalWhat">' + journal.What + '</div>'; | |
| html += '<div class="journalView">View</div>'; | |
| html += '</div>'; | |
| } //end for loop | |
| $('#journalsList').html(html); | |
| $('.journalRow').on('click', function(){ | |
| _journalIDEditing = $(this).attr('id'); | |
| // alert(_goalIDEditing); | |
| EditCompletedJournal(data); | |
| MovePageLeft('#pageJournalCreate', _currentPage); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment