首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >关闭google脚本中的modalDialogue框后运行代码

关闭google脚本中的modalDialogue框后运行代码
EN

Stack Overflow用户
提问于 2021-05-06 06:17:27
回答 1查看 103关注 0票数 0

单击ID为"submitButton“的按钮后,我将尝试关闭modal对话框并在函数对象中运行代码。

代码语言:javascript
运行
复制
var FuncObj = {
checker:checker
checker2:checker2
};

以下是我的HTML

代码语言:javascript
运行
复制
<!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被正确地呈现,但是当我单击按钮时什么都不会发生:

代码语言:javascript
运行
复制
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");  
}
}

下面是函数代码的调用:

代码语言:javascript
运行
复制
function runThatFunction(functionName){ FuncObj[functionName]();}

代码顺序如下-

上面的

  1. First " test (functionName)“将运行。如果它处于条件2,则当用户单击ID为"submitButton”的按钮时,将向用户显示来自
  2. 的functionName对话框。模态对话框应该关闭并运行作为参数传递的函数,以测试上面的'1‘中的函数。

从上面的顺序我被卡在第二位了。无法关闭modalDialogue框并运行它后面的任何函数。

EN

回答 1

Stack Overflow用户

发布于 2021-05-07 23:35:29

若要在关闭后运行代码,请添加要在google.script.host.close();之后运行的代码。请记住,这只会工作,关闭是通过调用close()函数完成的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67412795

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档