om/public/createMessage.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

const CreateMsgRouter = {
template: `
<div class="card om-card">
<h5>Neue Nachricht erstellen</h5>
<form class="new-msg-form" @submit.prevent=createMsg>
<div class="form-group bmd-form-group">
<label class="bmd-label-floating">Betreff</label>
<input type="text" class="form-control" id="subject">
</div>
<div class="form-group bmd-form-group">
<label class="bmd-label-floating">Tags</label>
<input type="text" class="form-control" id="tag">
</div>
<div class="form-group">
<label class="bmd-label-floating">Nachricht</label>
<textarea class="form-control" id="message" rows="5"></textarea>
</div>
<div class="form-group">
<label class="bmd-label-floating">User</label>
<textarea class="form-control" id="user"></textarea>
</div>
<button class="btn btn-default"><a @click="$router.go(-1)">ABBRECHEN </a></button>
<button type="submit" class="btn btn-raised om-btn">SENDEN</button>
</form>
</div>
`,
data: function () {
2018-12-12 15:56:09 +01:00
return {};
},
methods: {
createMsg: function() {
var subject=$("#subject").val();
var message=$("#message").val();
var tag=$("#tag").val();
var user=$("#user").val();
console.log ("Message Created: "+id+" "+tag+" "+message+" "+user);
$.ajax ({ url: "/api/createMsg", data: {subject: subject, tag: tag, message: message, user: user}, method: "POST" }) .done (have_result) .fail (have_error);
function have_result (res) {
console.log (res);
}
function have_error (err) {
console.log ("error:" + err.responseText);
console.log (err);
}
},
},
2019-01-16 17:38:57 +01:00
mounted: function() {
if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign();
},
};