53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
$(function () {
|
|
|
|
function fAddBericht(b) {
|
|
var dit = this;
|
|
this.berichtid = b.id;
|
|
this.kort = ko.observable(b.samenvatting);
|
|
this.lang = ko.observable(b.inhoud);
|
|
this.startdatum = ko.observable(b.datum);
|
|
}
|
|
|
|
mh.initBerichtenModel = function () {
|
|
if (mh.BerichtenModel !== undefined) {
|
|
mh.BerichtenModel.initModel();
|
|
}
|
|
else {
|
|
mh.BerichtenModel = {
|
|
nieuwtjes : ko.observableArray([]),
|
|
admin : ko.observable(false),
|
|
|
|
initBindings: function () {
|
|
var self = mh.BerichtenModel;
|
|
|
|
if (!ko.dataFor(document.getElementById('pagberichten'))) {
|
|
ko.applyBindings(mh.BerichtenModel, document.getElementById("pagberichten"));
|
|
}
|
|
|
|
self.initModel();
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
initModel: function () {
|
|
var self = mh.BerichtenModel;
|
|
$.post("index.php/monpas/berichten/getBerichten/", function(data){
|
|
self.nieuwtjes.removeAll();
|
|
if (data) {
|
|
$.each(data, function (i, p) {
|
|
self.nieuwtjes.push(new fAddBericht(p));
|
|
});// each
|
|
}
|
|
},'json');
|
|
},
|
|
|
|
}; // definition van model
|
|
|
|
mh.BerichtenModel.initBindings();
|
|
|
|
}
|
|
; // else
|
|
}// function initBerichtenModel
|
|
}); |