2017-03-08 11 views
0

イベントを編集するときにfullcalendarでこの問題が発生しますが、別のイベントを編集しようとすると、編集は常に変更を取得します。javascript Fullcalendarはイベントを編集しようとすると、最初にクリックしたものを編集します。

eventClick: function(calEvent, jsEvent, view) { 
      var title = calEvent.title; 
      alert(calEvent.idcita); 
      var idcita = calEvent.idcita; 
      $("#titulo2").val(title); 
      $("#idCita").text(idcita); 
      $("#startTime").html(moment(calEvent.start).format('D MMM h:mm A')); 
      $("#endTime").html(moment(calEvent.end).format('D MMM h:mm A')); 
      $("#eventInfo").html(calEvent.description); 
      $("#eventContent").dialog({ modal: true, title: calEvent.title, width:350}); 


     $(".antosubmit2").on("click", function() { 
      var title = $("#titulo2").val(); 
      idcita = $("#idCita").text() 
     if (title) { 
       calEvent.title = title; 
       var startw = calEvent.start; 
       var endedw = calEvent.end; 
       started = moment(startw,'YYYY-MM-DD hh:mm A'); 
       ended = moment(endedw,'YYYY-MM-DD hh:mm A'); 
      $.ajax({ 
        url: '/calendar/mod_cita', 
        data: 'id='+idcita+'&title='+calEvent.title+'&start='+started.format('YYYY-MM-DD HH:MM:SS')+'&end='+ended.format('YYYY-MM-DD HH:MM:SS'), 
        type: 'POST', 
        dataType: 'json', 
        success: function(response){ 
         // event.id = response.eventid; 
         calEvent.idcita = response.id; 
         $('#calendar').fullCalendar('updateEvent',calEvent); 
         console.log('Se edito correctamente'); 
        }, 
        error: function(e){ 
        // console.log(e.responseText); 
        } 

        }); 
       alert('dentro de editar:'+idcita+'y el evento es:'+calEvent.idcita); // Here I get the correct id for the clicked event but always the same calEvent (clicked the first time) 

     $('#titulo2').val(''); 
      $('#calendar').fullCalendar('rerenderEvents') 
      $('#calendar').fullCalendar('refresh') 
     $('#calendar').fullCalendar('unselect'); 
     $("#eventContent").dialog('close'); 

     }; 
    }); 

は、私はドキュメントを何度も読んだが、私はこれを把握することはできません、なぜ私が滞在をクリックした最初のイベントが選択されているよう? .fullcalendar( 'unselect')メソッドを使用しています。 機能を追加してもよろしいですか サイズ変更作業OK何度試しても問題ありません 1つの日付から他の作品に変更しても問題ありません。 削除1つまたは複数のイベントを削除できます。

しかし、編集できるのは1イベントのみです。

答えて

0

エラーが見つかりました。これがそのコードです。私は、ダイアログボタンの機能の中にajaxを置く必要があります。

eventClick: function(calEvent, jsEvent, view) { 
      var title = calEvent.title; 
      var idcita = calEvent.idcita; 
      var origEvent = calEvent; 
      $("#titulo2").val(title); 
      $("#idCita").text(idcita); 
      $("#startTime").html(moment(calEvent.start).format('D MMM h:mm A')); 
      $("#endTime").html(moment(calEvent.end).format('D MMM h:mm A')); 
      $("#eventInfo").html(calEvent.description); 
      $("#eventContent").dialog({ 
       sutoOpen: false, 
       modal: true, 
       draggable: true, 
       title: calEvent.title, 
       width:350, 
      buttons: { 
    "Salvar": function() { 
     var title = $("#titulo2").val(); 
      idcita = $("#idCita").text() 
       calEvent.title = title; 
       var startw = calEvent.start; 
       var endedw = calEvent.end; 
       started = moment(startw,'YYYY-MM-DD hh:mm A'); 
       ended = moment(endedw,'YYYY-MM-DD hh:mm A'); 
      $.ajax({ 
        url: '/calendar/mod_cita', 
        data: 'id='+idcita+'&title='+calEvent.title+'&start='+started.format('YYYY-MM-DD HH:MM:SS')+'&end='+ended.format('YYYY-MM-DD HH:MM:SS'), 
        type: 'POST', 
        dataType: 'json', 
        success: function(response){ 
         // event.id = response.eventid; 
         calEvent.idcita = response.id; 
         $('#calendar').fullCalendar('updateEvent',calEvent); 
         console.log('Se edito correctamente'); 
        }, 
        error: function(e){ 
        // console.log(e.responseText); 
        } 

        }); 

     $('#titulo2').val(''); 
      $('#calendar').fullCalendar('rerenderEvents') 
      $('#calendar').fullCalendar('refresh') 
     $('#calendar').fullCalendar('unselect'); 
     //$("#eventContent").dialog('close'); 
     // $('.antoclose2').click(); 

     $(this).dialog("close"); 
    } 
} 
      }); 
      $("#eventContent").dialog('open'); 

     }, 
+0

回答を投稿するのではなく、質問を編集する必要があります。 –

+0

申し訳ありませんが、私はそれを自分で把握しています。今質問を正しく編集する必要がありますか? – hugmax

関連する問題