Skip to content

Instantly share code, notes, and snippets.

@anakaine
Created September 4, 2019 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anakaine/c787fd4cb524630063d1a68b1f7f3b9e to your computer and use it in GitHub Desktop.
Save anakaine/c787fd4cb524630063d1a68b1f7f3b9e to your computer and use it in GitHub Desktop.
jQuery(document).on('click', '.gv-button-delete', async function (e) {
e.preventDefault(); //prevent submission
console.log('Intercepted delete button request');
var delLoc = "";
(function ($) {
var delLoc2 = $('.gv-button-delete').attr("href"); //capture default action, because we need the time-valid nonce
delLoc = delLoc2;
}(jQuery));
var objID = document.getElementById("input_4_40").value;
objID = parseInt(objID);
var iframe = document.getElementById("MapFrame1");
if (iframe) {
var iframeContent = (iframe.contentWindow || iframe.contentDocument);
//var result = iframeContent.WriteLog(objID); //call the fucntion from the iframe, and hopefully wait for a result.
var result = await f(iframeContent, objID);
console.log(result);
}
if (result == "error") {
console.log("Step 5")
console.log("There was an error with removing the feature");
} else if (result == "ok") {
console.log("Step 5")
console.log("The spatial delete completed correctly");
} else {
console.log("Step 5")
console.log("unexpected result of spatial delete")
}
});
async function f(iframeContent, objID) {
var result = iframeContent.WriteLog(objID); //call the fucntion from the iframe, and hopefully wait for a result.
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment