<!-- Folders -->
<ul class="folders" data-bind="foreach: folders">
<li data-bind="text: $data,
css: { selected: $data == $root.chosenFolderId() },
click: $root.goToFolder"></li>
</ul>
<!-- Mails grid -->
<table class="mails" data-bind="with: chosenFolderData">
<tbody data-bind="foreach: mails">
<tr>
<td data-bind="text: date"></td>
</tr>
</tbody>
</table>
function WebmailViewModel() {
// Data
var self = this;
self.folders = ['Inbox', 'Archive', 'Sent', 'Spam'];
self.chosenFolderId = ko.observable();
self.chosenFolderData = ko.observable();
// Behaviours
self.goToFolder = function(folder) {
self.chosenFolderId(folder);
simulatedResults = [{date: 'test1'}];
if (folder == 'Inbox'){
$(self.chosenFolderData = ({mails:simulatedResults}));
}
else if (folder == 'Archive') {
simulatedResults2 = [{date: 'test2'}];
$(self.chosenFolderData = ({mails:simulatedResults2}));
}
};
// Show inbox by default
self.goToFolder('Inbox');
};
ko.applyBindings(new WebmailViewModel());
--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+unsubscribe@googlegroups.com.