Custom Form Cancel Button and Temporary Event

I’m using my own custom form to create event. I’m opening form in Jquery UI Dialog. The issue is when I press cancel button from Jquery UI Dialog, the temporary event (unconfirmed added event) stays in calendar. I want my cancel button to work same like built-in lightbox. Following is the code

scheduler.showLightbox = function(event_id){
    $("#dialog-addUpdateAppointment").dialog('open');
}

You can add the next call to custom cancel action

scheduler._edit_stop_event(scheduler.getEvent(id),false);

Where id - id of event which creation was canceled.