Wedding Invitation
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.

guestbook-modal.blade.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <dialog id="guestbook" class="modal">
  2. <div class="modal-box w-11/12 max-w-5xl">
  3. <h3 class="text-lg font-bold">Ucapan</h3>
  4. <form id="speechForm">
  5. @csrf
  6. <label class="form-control w-full max-w-xs">
  7. <div class="label">
  8. <span class="label-text">Nama</span>
  9. </div>
  10. <input type="text" name="name" placeholder="Taip disini" class="input input-bordered input-sm input-accent w-full max-w-xs" />
  11. </label>
  12. <label class="form-control w-full max-w-xs">
  13. <div class="label">
  14. <span class="label-text">Ucapan anda</span>
  15. </div>
  16. <textarea class="textarea textarea-accent" name="speech" placeholder="Taip disini"></textarea>
  17. </label>
  18. </form>
  19. <div class="modal-action">
  20. <form method="dialog" id="closeSpeechForm"></form>
  21. <button type="button" class="btn bg-babybluedark" id="submitSpeechForm">Hantar</button>
  22. <button type="button" class="btn" id="submitCloseSpeechForm">Tutup</button>
  23. </div>
  24. </div>
  25. </dialog>
  26. @push('script')
  27. <script>
  28. $(document).ready(function() {
  29. $('#submitCloseSpeechForm').click(function(e) {
  30. $('#closeSpeechForm').submit();
  31. });
  32. $('#submitSpeechForm').click(function(e) {
  33. e.preventDefault();
  34. var formData = $('#speechForm').serialize();
  35. $.ajax({
  36. url: '{{ route('speech.save') }}',
  37. type: 'POST',
  38. data: formData,
  39. success: function(response) {
  40. $('#closeSpeechForm').submit();
  41. var alertContainer = $('.alert-success');
  42. alertContainer.find('span').text(response.message); // Set message text
  43. alertContainer.fadeIn().removeClass('hidden'); // Show the alert
  44. setTimeout(function() {
  45. alertContainer.fadeOut().addClass('hidden'); // Hide the alert after 5 seconds
  46. }, 3000);
  47. },
  48. error: function(xhr, status, error) {
  49. console.error('Error submitting form:', error);
  50. }
  51. });
  52. });
  53. })
  54. function showSuccessMessage(message) {
  55. // Create a dynamic success message element
  56. var successAlert = $('<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">' +
  57. '<span class="block sm:inline">' + message + '</span>' +
  58. '</div>');
  59. // Append the message to a suitable container in your HTML (e.g., modal, form, or body)
  60. $('#alert-success').append(successAlert);
  61. // Automatically remove the message after 3 seconds
  62. setTimeout(function() {
  63. successAlert.fadeOut('slow', function() {
  64. $(this).remove();
  65. });
  66. }, 3000); // 3 seconds
  67. // session()->forget('success');
  68. }
  69. </script>
  70. @endpush