Wedding Invitation
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

rsvp-modal.blade.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <dialog id="rsvp" class="modal">
  2. <div class="modal-box w-11/12 max-w-5xl">
  3. <h3 class="text-lg font-bold">RSVP</h3>
  4. <form id="rsvpForm">
  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">Bilangan</span>
  15. </div>
  16. <input type="number" name="member" placeholder="Taip disini" class="input input-bordered input-sm input-accent w-full max-w-xs" />
  17. </label>
  18. </form>
  19. <div class="modal-action">
  20. <form method="dialog" id="closeRsvpForm"></form>
  21. <button type="button" class="btn bg-babybluedark" id="submitRsvpForm">Hantar</button>
  22. <button type="button" class="btn" id="submitCloseRsvpForm">Tutup</button>
  23. </div>
  24. </div>
  25. </dialog>
  26. @push('script')
  27. <script>
  28. $(document).ready(function() {
  29. $('#submitCloseRsvpForm').click(function(e) {
  30. $('#closeRsvpForm').submit();
  31. });
  32. $('#submitRsvpForm').click(function(e) {
  33. e.preventDefault();
  34. var formData = $('#rsvpForm').serialize();
  35. $.ajax({
  36. url: '{{ route('rsvp.save') }}',
  37. type: 'POST',
  38. data: formData,
  39. success: function(response) {
  40. $('#closeRsvpForm').submit();
  41. if ('{{ session('success') }}') {
  42. showSuccessMessage('{{ session('success') }}');
  43. }
  44. },
  45. error: function(xhr, status, error) {
  46. console.error('Error submitting form:', error);
  47. }
  48. });
  49. });
  50. });
  51. function showSuccessMessage(message) {
  52. // Create a dynamic success message element
  53. var successAlert = $('<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">' +
  54. '<span class="block sm:inline">' + message + '</span>' +
  55. '</div>');
  56. // Append the message to a suitable container in your HTML (e.g., modal, form, or body)
  57. $('#alert-success').append(successAlert);
  58. // Automatically remove the message after 3 seconds
  59. setTimeout(function() {
  60. successAlert.fadeOut('slow', function() {
  61. $(this).remove();
  62. });
  63. }, 3000); // 3 seconds
  64. }
  65. </script>
  66. @endpush