Issue 717: duplicates events with select and modal
Status:  Done
Owner: ----
Closed:  Nov 2010
Reported by clement....@gmail.com, Nov 17, 2010
Hi everybody,
I use a JqModal plugin to display a dialog box with my title field and I want the element is created at the click of the button in this modal. But :

I have a problem of duplication of events when I was creating more than one element, the second is duplicated on the first and third on the first two etc...




<script type='text/javascript'>

	$(document).ready(function() {
	
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		var calendar = $('#calendar').fullCalendar({
			header: {
				left: 'prev,next,today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			selectable: true,
			selectHelper: true,
			unselectAuto:true,
			select:function( start, end, allDay, jsEvent){
						
          $('#event_calendar').jqmShow(); 	// on ouvre la modal
					$('#create_event').click(function(){
						
							$('#event_calendar').jqmHide(); // on ferme la modal
							calendar.fullCalendar('renderEvent',{
									title: $('#event_title').val(),
									start: start,
									end: end,
									allDay: allDay
									},true);
							calendar.fullCalendar('unselect');
								
					});
											
					$('#event_title').val('');
        },
			editable: true,
			events: [
						{
					title: 'Lunch',
					start: new Date(y, m, d, 12, 0),
					end: new Date(y, m, d, 14, 0),
					allDay: false
				},
				{
					title: 'Birthday Party',
					start: new Date(y, m, d+1, 19, 0),
					end: new Date(y, m, d+1, 22, 30),
					allDay: false
				}
			]
		});

	});

</script>


	<div id="content">

		<!-- MODAL -->
		<div class="modal rounded" id="event_calendar">
			<div class="modal_title rounded_t">
			  New event
			  </div>
			  <div class="modal_content">
			  
			  	<input type="text" id="event_title" name="event_title" value="" class="rounded"/>
			  	
					<a id="create_event" class="button"><img src="{$images_dir}navigation/new_session.png"/>Créer l'evenement</a>
						
			  
			  </div>
		</div>

		<div id='calendar'></div>
	
	
	</div>



Thanks for your help
Nov 21, 2010
Project Member #1 adamrs...@gmail.com
this seems to be a problem with the way you are attaching the click handler to the #create_event element. the handler is being attached multiple times. put that code outside of the select callback, after the initialization of fullcalendar.
Status: Done