From fc8250088bcd3fa2efa9c6538795fec92db65156 Mon Sep 17 00:00:00 2001 From: Evans Edem Ladzagla <30314824+evansree@users.noreply.github.com> Date: Thu, 28 Jul 2022 02:54:19 +0000 Subject: [PATCH] Update builder.js 1. Triggers Event on SaveAjax 2. Allows the ajax options to be modified before the ajax is called 3. Hence allowing you to add other parameters to be sent to the server such as anti forgery token, post id, etc 3. Allows the saveAjax to be aborted when false is returned. --- libs/builder/builder.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/builder/builder.js b/libs/builder/builder.js index 88556754..ca9f5053 100644 --- a/libs/builder/builder.js +++ b/libs/builder/builder.js @@ -1828,8 +1828,8 @@ Vvveb.Builder = { { data["html"] = this.getHtml(); } - - $.ajax({ + + var ajaxOpt = { type: "POST", url: saveUrl,//set your server side save script url data: data, @@ -1842,7 +1842,16 @@ Vvveb.Builder = { error: function (data) { alert(data.responseText); } - }); + }; + + var ajaxOptMod = $(window).triggerHandler("vvveb.saveAjax", ajaxOpt); + if (ajaxOptMod === false) + return; + + if( ajaxOptMod && $.isPlainObject(ajaxOptMod) ) + ajaxOpt = ajaxOptMod; + + $.ajax(ajaxOpt); }, setDesignerMode: function(designerMode = false)