SHARE
TWEET

Untitled

a guest Feb 14th, 2020 67 in 15 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var modalCalendar_request = null;
  2.   // Show modal
  3.   $('#modalCalendar').on('show.bs.modal', function (event) {
  4.     // modal & the event triggering the modal
  5.     var modal = $(this)
  6.     var e = $(event.relatedTarget)
  7.     // Update calendar
  8.     if (e.data('id')) {
  9.       modal.find('.modal-title').text('{{ __("Edit calendar") }} ' + e.data('id'))
  10.       modal.find('.modal-dialog form').attr('action', '{{ url_for("calendar.sources.api01") }}/' + e.data('id') )
  11.       modal.find('.modal-body input[name="name"]').val(e.data('name'))
  12.       modal.find('.modal-body input[name="uri"]').val(e.data('uri'))
  13.       modalCalendar_request = 'PUT'
  14.     }
  15.     // New calendar
  16.     else {
  17.       modal.find('.modal-title').text('{{ __("New remote calendar") }}')
  18.       modal.find('.modal-dialog form').attr('action', '{{ url_for("calendar.sources.api01") }}/')
  19.       modal.find('.modal-body input[name="name"]').val('')
  20.       modal.find('.modal-body input[name="uri"]').val('')
  21.       modalCalendar_request = 'POST'
  22.     }
  23.   });
  24.  
  25.  
  26.   // Post (new) data, modify current page
  27.   $("#calendar_form").ajaxSubmit({
  28.     data: function() {
  29.       return $(this).serialize();
  30.     },
  31.     headers: {
  32.       "X-Http-Method-Override": modalCalendar_request
  33.     },
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top