javascript - fullcalendar remove event by popup modal strange behavior -


i have made fullcalendar event remove popup modal. partly working there strange behavior. newbie this, have tried several different way can't make stange behavior away. , don't know how make jsfiddle reproduce exact behavior without copying code. code contains lot things. can't provide jsfiddle. , related code stated here. think has experience this. think can see through code. appreciated advice. have spent time on it. strange behavior event remove popup modal, removes other event closed close button. in following explanation contains details.

i have made this:

1) div code popup modal

<div class="modal fade" id="modalremove" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">   <div class="modal-dialog">     <div class="modal-content">       <div class="modal-header">         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>       </div>       <div class="modal-body">        <h4>are sure remove event?</h4>       </div>       <div class="modal-footer">         <button type="button" class="btn btn-default" id="close" data-dismiss="modal">close</button>         <button type="button" class="btn btn-danger" id="removebtn" data-dismiss="modal">remove</button>       </div>     </div>   </div> </div> 

2) when event clicked -> popup modal displays -> can choose (click) close button or remove button on popup modal

eventrender: function (event, element){       element.click(function() {         $('#modalremove').modal();         $('#eventtitle').html(event.title);         $("#removebtn").click(function() {                $('#calendar').fullcalendar('removeevents',event._id);          });     }); }, 

what working

  1. popup modal working
  2. close button, remove button working
  3. event removed when remove button pressed on popup modal

what strange behavior

  1. let's there 2 events: test1, test2 (image1)

enter image description here

  1. i clicked test1 event, popup modal appears (image2)

enter image description here

  1. then, click close button on popup test1 (not remove)-> popup disappeared -> test1 event still on fullcalendar should be. ====> until here works fine

  2. then, click test2 event-> popup modal appear image 2 -> press remove button test2 -> [problem]then both test1, test2 events removed

why removes both events after 1,2,3,4 steps?

try this:

eventrender: function(event, element) {   element.attr('href', 'javascript:void(0);');   element.click(function() {     //set modal values , open     $('#eventtitle').html(event.title);      // rebind remove button click handler     $("#removebtn").off('click').on('click', function(e) {         $('#calendar').fullcalendar('removeevents', event._id);     });      $('#modalremove').modal();   }); } 

note how click events unbound #removebtn button via off() prior binding specific event.

(in code every time clicked event in calendar new click handler event bound #removebtn. when clicked "remove" multiple handlers executed.)


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -