updating event details on front end after adding server side

Hi,

I’m using php to add an event, some logic is used find a film in the database by selecting the name (cinema scheduler) and the event is added using the films name, start and end time.

On the front end when you click to add the event the details are not updated, a refresh on the screen updates these but this isnt ideal as it sends you back to the first screen.

I’ve tried adding this in the client side

scheduler.attachEvent("onEventAdded", function(event_id,event_object){ var myObj = scheduler.getEvent(event_id); scheduler.setEventText(event_id, myObj.event_name); });

And can get the name of the event, but because the end time is determined from the film database i can’t update the setEndDate using the same method. Any ideas what i should use?

I see also that setEventEndDate(event_id, end_date) takes a date object to update, i’ve tried using php to update the end_date but with no luck.

The problem is because i’m not setting the end date on the lightbox, i’m doing it from a row in a database, there is no way of updating the end time on the displayed event on the front end without reloading the data, maybe i can figure this out with ajax but can anyone figure out a simpler solution?

The data saving is async, so you can’t just use onEventAdded handler.

on client side

dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){ if (action == "insert" || action == "update") scheduler.getEvent(tid).end_date = new Date(tag.getAttribute("date")); })

on server side

function setBackData($action){ $action->set_response_attribute("date", some_custom_value); } $scheduler->event->attach("afterInsert", setBackData);

Above code adds some custom data to the server side response, and instructs client side to set that value as an end date for the related event.

thanks for the reply Stanislav, sorry it’s took me this long to respond, i never subscribed to notifications.

The code works in the fact that it updates the event without refresh, one weird quirk is at first it doesnt seem to work and nothing happens but as soon as you click on the top of the event it seems to fire and updates, very strange. I’ve put alerts and it is defo the inserted action that does the updating it just doesnt seem to update with a click on the top.

And by the way for anyone else it is inserted instead of insert

if (action == "inserted" || action == "update")

Hello,

Following line
scheduler.getEvent(tid).end_date = new Date(tag.getAttribute(“date”));
only updates event property. Try calling refresh view (setCurrentView for the same date and view) to re-render all events. Or updateEvent.

Kind regards,
Ilya

Hi,

Following on from this topic, everything is working ok in Chrome but in all the other browsers my event disappears, maybe this is a cross browser issue as i have no errors in firebug. My code is below, maybe there is another way to update an events end date and name without refreshing the view

[code] dp.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){
if (action == “inserted” || action == “update”){
scheduler.getEvent(tid).end_date = new Date(tag.getAttribute(“date”)); //change data of event
if(tag.getAttribute(“typeOfEvent”) != ‘film’ && tag.getAttribute(“typeOfEvent”) != ‘event1’ && tag.getAttribute(“typeOfEvent”) != ‘event2’ && tag.getAttribute(“typeOfEvent”) != ‘event3’ ){
scheduler.getEvent(tid).text = tag.getAttribute(“typeOfEvent”);
}

			scheduler.updateEvent(tid); // render updated event
		}
		});[/code] 

I’ve tried scheduler.setCurrentView(scheduler.getState().date, scheduler.getState().mode); but it just messes up the scheduler.

Kind Regards

Chris

tag.getAttribute(“date”)
Can you provide the sample of date value stored in XML? In which format it is stored?
Latest version of FF have changes in date parsing which can cause the problem, and your code must need to be updated according to the date format.

Also, if you are using FF9 - be sure to update to FF10, as FF9 has known bugs