prevent modal from opening

328 Views Asked by At

I'm working on a Fullcalendar project. This is how I open my modal to edit Events:

eventClick: function eventClick(event) {
  $('#editNewEvent').modal('show');
  //function....
}

and this is how I delete them:

eventRender: function eventRender( event, element, view ) {

  if (view.name == 'listDay') {
    element.find(".fc-list-item-time").append("<span class='closeon'>X</span>");                            
  } else {
    element.find(".fc-content").prepend("<span class='closeon'>X</span>");
  }

  element.find(".closeon").on('click', function() {
    $('#editNewEvent').modal('hide');

    if(event.nomeUtente == $("#nomeUtente").data('value')){
      var deleteMsg = confirm("Vuoi davvero eliminare " + event.title + "?");
      if (deleteMsg == true) {                      
        $.ajax({
          url: 'eventi/deleteEvent.php',
          type: 'POST',
          data:  {_id: event.idAssenza, nomeUtente: event.nomeUtente}
        })

        $('#calendar').fullCalendar('removeEvents',event._id);
      }
    }
    else {
      alert('Non puoi eliminare questo evento!');
    } 
  });
}
                                

When I trigger the else part, after the alert, it appared the modal to edit events. Is there a way not to trigger the editEvents modal in this case?

I've already tried to add: $('#editNewEvent').modal('hide'); but It show up anyways


This is an event from my calendar: event

Basically when I click on the event normally, it appared the modal to edit the event.

When I click on the X, at first my code check if the current $_SESSION[user] is the same person as the one that create the event (if(event.nomeUtente == $("#nomeUtente").data('value')){). If it's the same than it appared the confirm alert and proceded to delete the event; if not it appared an alert where it's says "'Non puoi eliminare questo evento!'" and my problem is in this last case; because after this alert it appared the modal to edit the events and I dont want that.

0

There are 0 best solutions below