-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDnnSimpleArticle.js
59 lines (48 loc) · 1.43 KB
/
DnnSimpleArticle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* coming soon, this isn't currently used and doesn't currently work
stay tuned for Version 2.5
*/
function Article(a, selectedArticle) {
this.id = a.ArticleId;
this.Title = a.Title;
this.Description = a.Description;
this.Body = a.Body;
this.url = a.url;
}
var viewModel = {
articles: ko.observableArray([])
};
$(function () {
/* Initialize AJAX so we can simplify individual calls */
var sf = $.ServicesFramework(414); //production id needs a module id here afaik
//var sf = $.ServicesFramework(381); //development id
sf.getAntiForgeryProperty();
var mappedFromServer;
var data = {};
data.portalId = 0; // development/production id
data.sortAsc = true;
$.ajax({
type: "POST",
cache: false,
//don't forget about siteurls.config replacement used below
url: '/desktopmodules/DnnSimpleArticle/API/DnnSimpleArticle.ashx/GetAllArticles',
data: data
}).done(function (data) {
viewModel.articles = ko.utils.arrayMap(data.Articles, function (article) {
return new Article(article);
});
ko.applyBindings(viewModel);
}).fail(function () {
alert('Sorry failed to load articles');
});
});
/*
sample HTML
<!-- ko foreach: articles -->
<div>
<h1 data-bind="html:Title">
</h1>
<div data-bind="html:Body">
</div>
</div>
<!-- /ko -->
*/