Browse Source

home.js ausgebessert

pull/1/head
Edwina Barbalan 6 years ago
parent
commit
eeaf7b428c
1 changed files with 47 additions and 21 deletions
  1. 47
    21
      public/home.js

+ 47
- 21
public/home.js View File

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"
:msg="messages[id] || {}" :msg="messages[id] || {}"
></MsgCard> ></MsgCard>
</div>`, </div>`,
data: function () {
return {
messagelist: _messagelist,
messages: _messages,
};
},
methods: {
refresh_messages: function () {
_messages.push({ //////// alt
id: 42,
subject: "xxx",
message: "warum habt ihr auch so viel",
user: "nobody",
tags: "foo"
});
},
},
data: function () {
return {
messagelist: _messagelist,
messages: _messages,
};
},
methods: {
refresh_messages: function () {
_messages.push({ //////// alt
id: 42,
subject: "xxx",
message: "warum habt ihr auch so viel",
user: "nobody",
tags: "foo"
});
},
},


/*mounted: function() {
this.refresh_messages();
}*/
/*mounted: function() {
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…
Cancel
Save