onLimitViolation exception with dhtmlx.confirm

Hello,

I need some help to add exception to event onLimitViolation please.

I do some tests in the onlimitViolation and in a specific case, I have to launch a confirm popup (dhtmlx.confirm), but when it returns true it doesn’t work, it doesn’t launch lightbox.

I think the return true works, at this moment only, for the confirm.

Here is my code :


		scheduler.attachEvent("onLimitViolation", function  (ev_id, event){

			var is_new = true;
			var reservby_sid = event.reservsid;

			ev_format = scheduler.date.date_to_str("%Y%m%d%H%i");
			var start = ev_format(scheduler.getEvent(ev_id).start_date);
			var now   = moment().format("YYYYMMDDHHmm");

			if(ev_id.toString().substring(0,3)=='RES'){
				is_new = false;
			} else {
				is_new = true;
			}

			if(is_new){

				if(start>now){

					dhtmlx.confirm({
						id: "confwind",
						type: "confirm",
						width: "600px",
						ok: "Oui",
						cancel: "Non",
						text:   "confirm text",
						callback: function (result) {
							return result;
						}
					});

				} else {
					dhtmlx.message.hide("limit_mgs");
					dhtmlx.message({
						id:"limit_mgs",
						text:"limit message 1",
						expire:4000,
						type:"msgerr"
					});
				}

			} else {
				... launch a function

				} else {
					dhtmlx.message.hide("limit_mgs2");
					dhtmlx.message({
						id:"limit_mgs2",
						text:"limit message2",
						expire:3000,
						type:"msgerr"
					});

				}
			}
			return false;

		});

Thanks for your help

Loïc

Hello,
dhtmlx.confirm doesn’t stop the code execution (unlike native window.confirm), so when you show dhtmlx.confirm from onLimitViolation handler it continues execution and returns ‘false’ and the operation gets canceled, returning value from an async callback of dhtmlx.confirm won’t do anything.
The simplest solution in your case would be to use a native confirms, i.e.

[code]if(confirm(“confirm text”)){

}[/code]If you use the async confirms, you’ll have to do processing (e.g. rollback values if user clicked ‘cancel’) manually

OK, thank you for your answer. I will find a way to make it differently (after showlightbox).

Do you think that you will implement the stop code execution function in dhtmlx.confirm in some future version?

Hi,
we’re considering something similar. It won’t be the ability to stop the code (which i think is not possible in browser js), but the support of deferred handlers - i.e. ability to return a promise object instead of a primitive value from an event handler. Although, it’s still is only in consideration phase so I can’t give any timelines on when and if it will be implemented

Ok, thanks for your answer. I’ll stay tuned to future updates.