Skip to content

Instantly share code, notes, and snippets.

@dacur
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save dacur/6166696a960b26b437d8 to your computer and use it in GitHub Desktop.

Select an option

Save dacur/6166696a960b26b437d8 to your computer and use it in GitHub Desktop.
User uses dropbox to select a search term. Clicks button to initialize search. Any result that does not match will have class 'displayNone' applied to it. (Build function runs first, displays journals) ****OPTIONAL: call from on change instead of on click. When dropdown state changes, the function will be called. See code below.
function SortJournalsWho(){
_selectedWho = $('#journalWhoTagSort option:selected').val();
$('.journalWho').each(function(){
if($(this).html()!=_selectedWho){
$(this).parent().addClass('displayNone');
}
});
}
function BuildCompletedJournals(data){
// alert(JSON.stringify(data));
var i = 0;
var html = '';
for(i=0; i<data.length; i++){
var journal = data[i];
var date = moment(journal.JournalDate).format("MMM Do YYYY");
// alert(journal.ID);
html += '<div class="journalRow" id="' + journal.ID + '">';
html += '<div class="journalName">' + journal.Title + '</div>';
html += '<div class="journalDate">' + date + '</div>'
html += '<div class="journalHidden journalWho">' + journal.Who + '</div>'
html += '<div class="journalHidden journalWhat">' + journal.What + '</div>'
html += '</div>'
}
$('#journalsList').html(html);
$('.journalRow').on('click', function(){
_journalIDEditing = $(this).attr('id');
// alert(_goalIDEditing);
EditCompletedJournal(data);
MovePageLeft('#pageJournalCreate', _currentPage);
});
}
// *******OPTIONAL to sort on change instead of btn click. Put this in page load JS.
$('#journalWhoTagSort').change(function(){
SortJournalsWho();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment