diff --git a/public/home.js b/public/home.js index 1bf5546..f95329e 100644 --- a/public/home.js +++ b/public/home.js @@ -23,34 +23,31 @@ const HomeRouter = { tags: "foo" }); },*/ - list_messages: function () { - console.log("egal"); - $.get('api/ids/').done(function (jd) { - // _messagelist = jd; - _messagelist.splice(0, _messagelist.length); - _messagelist.push.apply(_messagelist, jd); - console.log("egal2"); - //$('#xxx').text(jd[0]); - for (var e in jd) { - if (!_messages[jd[e]]) { - get_insert_message(jd[e]); - } - } - }).fail(function (e, f, g) { - console.log("egal3: " + e + f + g); - }); - } + list_messages: function () { + $.ajax({url: "/api/ids", method: "GET"}) + .done(jd => { + // NICHT SO wg. Vue: _messagelist = jd; + _messagelist.splice(0, _messagelist.length); + _messagelist.push.apply(_messagelist, jd); + for (var e in jd) { + if (!_messages[jd[e]]) { + get_insert_message(jd[e]); + } + } + }).fail(function (e, f, g) { + console.log("err: " + e + f + g); + }); + } }, - mounted: function() { - this.list_messages(); - /*this.refresh_messages();*/ + mounted: function () { + this.list_messages(); + //this.refresh_messages(); } }; -function get_insert_message(msg_id) { - $.get(api/msg/{msg_id}).done(function (msg) { - // _messages[id] = msg; +function get_insert_message(id) { + $.ajax({ url: "/api/msg/"+id, method: "GET" }).done(function (msg) { Vue.set(_messages, id, msg); }).fail(function (e, f, g) { console.log("cannot load " + id + ".json: " + e + f + g); diff --git a/public/index.html b/public/index.html index 21560da..d3cde5a 100644 --- a/public/index.html +++ b/public/index.html @@ -74,7 +74,7 @@