After having created an event, I got a test to check if this new event his for an user who already got one… in order to avoid multiple events for a same user.
If an event already exists for this user, I delete the new one.
“date_start” has null value or is not an object"
below my code
var evs = scheduler.getEvents(new Date(2000,1,1),new Date(2050,1,1));
for (var i=0; i<evs.length; i++)
if (ChaineId.indexOf(IdPresid)==-1) // my test (event_id must not be in ChaineId)
alert('just one event );
thanks for your help
component doesn’t expect that event will be deleted in the onEventCreated handler, which is cause the issue.
Instead of it, you can use onBeforeDrag event which occurs when user tries to create event by d-n-d ( or change size|position of an existing event ) - returning false from the handler will block creation of new event.
Next may be used with your current solution, but it based on inner logic and may not work correctly ( never was tested )
alert('just one event );
scheduler._drag_id = this._drag_mode = null;
Thanks for your quick answer…
I’ve tried to put the code in the onEventCreated event has seen in this topic
but maybe I didn’t understand the aim of this topic.
So I will try your solution with OnBeforeDrag…
I've tried to put the code in the onEventCreated event has seen in this topic
Normally you can change properties of event - alter start and end time for example, but it not purposed for event deleting.
I solved my problem…
In fact, the problem was that in the onCreatedEvent.
I thought that this event was called after event creation, but it’s called after event initialisation (date_start, id, text…) but the focus is still on the event until the end of the function, so no date_end.
I can not use the onBeforeDrag because my user must be able to change his other event.
So I keep my test in onCreatedEvent, initialize a global variable which I test after in the onEventAdded
below my code, if this can help others
var evs = scheduler.getEvents(new Date(2000,1,1),new Date(2050,1,1)); /browse all events/
for (var i=0; i<evs.length; i++) /* I retrieve in a string the user_id of each event (stored in ‘details’ in XML and compare to current user_id which is stored in UserId */
if (AllUserId.indexOf(UserId)!=-1) // the test
/… end of initialization/
alert(‘Just one event per user’);
maybe the post subject can be replace by “limiting to one event per user”
Thanks to all… scheduler as all your components is great… good jod