Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

createMessage.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const CreateMsgRouter = {
  2. template: `
  3. <div class="card om-card">
  4. <h4>Neue Nachricht erstellen</h4>
  5. <form class="new-msg-form" @submit.prevent=createMsg>
  6. <div class="form-group">
  7. <label class="bmd-label-floating">User*</label>
  8. <input type="text" class="form-control" id="user">
  9. </div>
  10. <div class="form-group bmd-form-group">
  11. <label class="bmd-label-floating">Betreff*</label>
  12. <input type="text" class="form-control" id="subject">
  13. </div>
  14. <div class="form-group bmd-form-group">
  15. <label class="bmd-label-floating">Tags</label>
  16. <input type="text" class="form-control" id="tag">
  17. </div>
  18. <div class="form-group">
  19. <label class="bmd-label-floating">Nachricht*</label>
  20. <textarea class="form-control" id="message" rows="5"></textarea>
  21. </div>
  22. <button class="btn btn-default"><a @click="$router.go(-1)">ABBRECHEN </a></button>
  23. <button type="submit" class="btn btn-raised om-btn"><a @click="$router.push('/home')">SENDEN</a></button>
  24. </form>
  25. </div>
  26. `,
  27. data: function () {
  28. return {};
  29. },
  30. methods: {
  31. createMsg: function() {
  32. var subject=$("#subject").val();
  33. var message=$("#message").val();
  34. var tag=$("#tag").val();
  35. var user=$("#user").val();
  36. console.log ("Message Created: "+tag+" "+message+" "+user);
  37. $.ajax ({ url: "api/createMsg", data: {sub: subject, mess: message, use: user, ta: tag}, method: "POST" }) .done (have_result) .fail (have_error);
  38. function have_result (res) {
  39. console.log (res);
  40. }
  41. function have_error (err) {
  42. console.log ("error: " + err.responseText);
  43. console.log (err);
  44. }
  45. },
  46. },
  47. mounted: function() {
  48. if ($(this).bootstrapMaterialDesign)
  49. $(this).bootstrapMaterialDesign();
  50. },
  51. };