Proper way to re-open lightbox for invalid event (Server)

Hello,

I am trying to automatically re-open the lightbox when an event is added and the server responds with an invalid state e.g.

<data><action type="invalid" sid="1000" tid="1000"/></data>

I tried attaching these events to a custom function:

// dataprocessor has already been initialized
dataprocessor.attachEvent("onAfterUpdate", updated_handler);
scheduler.attachEvent("onEventCancel", cancelled_handler);
// the handler
function updated_handler(sid, action, tid, btag){
    if (action == "invalid"){
        scheduler.showLightbox(sid);
        return true;
    }
    return true;
}

function cancelled_handler(event_id, is_new_event){
    if (event_id in scheduler._dataprocessor._invalid){
        delete scheduler._dataprocessor._invalid[event_id]
        scheduler.deleteEvent(event_id);
        return true;
    }
    return true;
}

It seems to work for the first event and then I get this error:
[color=red]
Uncaught TypeError: Cannot read property ‘!nativeeditor_status’ of undefined

Any idea on how to deal with this

Thanks

When you are calling deleteEvent - do you want to delete it only from client side or delete in db as well?

In first case

function cancelled_handler(event_id, is_new_event){ if (event_id in scheduler._dataprocessor._invalid){ window.setTimeout(function(){ delete scheduler._dataprocessor._invalid[event_id] dataprocessor.ignore(function(){ scheduler.deleteEvent(event_id); }); }); return true; } return true; }

In second case

function cancelled_handler(event_id, is_new_event){ if (event_id in scheduler._dataprocessor._invalid){ window.setTimeout(function(){ scheduler.deleteEvent(event_id); },1); return true; } return true; }

Thanks Stanislav. Will try and post feedback.