单击ID为"submitButton“的按钮后,我将尝试关闭modal对话框并在函数对象中运行代码。
var FuncObj = {
checker:checker
checker2:checker2
};
以下是我的HTML
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js">.
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<style>
.padd5{
padding: 5px 0;
}
</style>
</head>
<body>
<div class="continue-button">
<button class='blue' id="submitButton">Continue </button>
</div>
</body>
<script>
$("#submitButton").click(
google.script.run.withSuccessHandler(close).runThatFunction(checker);`
function close(){
google.script.host.close();
}
</script>
</html>
下面是呈现HTML的代码,HTML被正确地呈现,但是当我单击按钮时什么都不会发生:
function test(functionName) {
if (condition1){
FuncObj[functionName]();
}
if(condition2) {
var html = HtmlService
.createTemplateFromFile('unpaid')
.evaluate()
.getContent();
var finalHtml = HtmlService.createTemplate(html).evaluate().setWidth(300).setHeight(560);
SpreadsheetApp.getUi()
.showModalDialog(finalHtml, 'test');
}
else {
SpreadsheetApp.getActive().toast("Exhausted");
}
}
下面是函数代码的调用:
function runThatFunction(functionName){ FuncObj[functionName]();}
代码顺序如下-
上面的
从上面的顺序我被卡在第二位了。无法关闭modalDialogue框并运行它后面的任何函数。
发布于 2021-05-07 23:35:29
若要在关闭后运行代码,请添加要在google.script.host.close();
之后运行的代码。请记住,这只会工作,关闭是通过调用close()
函数完成的。
https://stackoverflow.com/questions/67412795
复制相似问题