var myViewModel = {
_id: ko.observable(''),
username: ko.observable(''),
firstName: ko.observable(''),
list: ko.observableArray([])
};
ko.applyBindings(myViewModel);
We need to create a dummy "list" observableArray attribute to fetch all objects from API
var kr = new KnockRest('http://localhost:3000/api/users', myViewModel, '_id');
$('#btnList').click(function() {
kr.list();
});
$('#btnSave').click(function() {
kr.save();
});
$('#btnDelete').click(function() {
kr.delete();
});
$('body').on('click', '.load', function() {
kr.get($(this).attr('id'));
});