home.js ausgebessert
This commit is contained in:
parent
013bdb4ce1
commit
eeaf7b428c
@ -1,5 +1,5 @@
|
|||||||
const HomeRouter = {
|
const HomeRouter = {
|
||||||
template: `
|
template: `
|
||||||
<div id="om-msg-cards">
|
<div id="om-msg-cards">
|
||||||
<MsgCard
|
<MsgCard
|
||||||
v-for="id in messagelist"
|
v-for="id in messagelist"
|
||||||
@ -7,25 +7,51 @@ const HomeRouter = {
|
|||||||
:msg="messages[id] || {}"
|
:msg="messages[id] || {}"
|
||||||
></MsgCard>
|
></MsgCard>
|
||||||
</div>`,
|
</div>`,
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
messagelist: _messagelist,
|
messagelist: _messagelist,
|
||||||
messages: _messages,
|
messages: _messages,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refresh_messages: function () {
|
refresh_messages: function () {
|
||||||
_messages.push({ //////// alt
|
_messages.push({ //////// alt
|
||||||
id: 42,
|
id: 42,
|
||||||
subject: "xxx",
|
subject: "xxx",
|
||||||
message: "warum habt ihr auch so viel",
|
message: "warum habt ihr auch so viel",
|
||||||
user: "nobody",
|
user: "nobody",
|
||||||
tags: "foo"
|
tags: "foo"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/*mounted: function() {
|
/*mounted: function() {
|
||||||
this.refresh_messages();
|
this.refresh_messages();
|
||||||
}*/
|
}*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function get_insert_message(id) {
|
||||||
|
$.get(id + ".json").done(function (msg) {
|
||||||
|
// _messages[id] = msg;
|
||||||
|
Vue.set(_messages, id, msg);
|
||||||
|
}).fail(function (e, f, g) {
|
||||||
|
console.log("cannot load " + id + ".json: " + e + f + g);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$(document).ready(function () {
|
||||||
|
console.log("egal");
|
||||||
|
$.get('list.json').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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user