Cose lightbox on ESC key and outside click of lightbox

To hide lightbox onclick outside lightbox, you should just listen click event and if click target is cover you should close lightbox. Someting like this:

dhtmlxEvent(document.body, "click", function(e){
	var boxId = scheduler.getState().lightbox_id;
	if(boxId){
		var el=e?e.target:event.srcElement,
			cover = document.querySelector(".dhx_cal_cover");
			
		if(cover && cover.contains(el)){
			var box = scheduler.getLightbox();
			scheduler.endLightbox(false, box);
		}
	}
});

Lightbox cancels by default after clicking ESC key.

See example: docs.dhtmlx.com/scheduler/snippet/ad816bcc

1 Like