【问题标题】:Refresh HTML service webpage on click点击刷新 HTML 服务网页
【发布时间】:2013-08-30 08:37:32
【问题描述】:
Mypage.html
<div class="seven"><button onClick="Submit()">submit</button> </div>

<script type="text/javascript">
        function submit() {
            google.script.run.scores(document.forms[0]);
        }
</script>

....

Javascript.gs
function scores(form){
Logger.log("I am called")
}

上面的代码完美运行,但是每次单击按钮时,我都希望 HTML 模板化/部署的网页也加载/重新加载/刷新...

我尝试添加

google.script.run.scores(document.forms[0]); (continued from above code, hence line repeated))
google.script.host.refresh (basically got the idea from host.close)
google.script.host.reload
google.script.host.load 

请有人帮我获取正确的代码,通过该代码的 onClick 按钮调用分数函数(目前正在工作)以及刷新页面。

注意:我希望它刷新,原因是 - 在提交时,数据被推送到 GSheet,在刷新时再次在下拉列表中调用......

提前谢谢....

【问题讨论】:

    标签: html google-apps-script google-docs google-docs-api google-caja


    【解决方案1】:

    据我所知,没有办法在 GAS 中刷新模板化的 HTML。

    即使可以,这也类似于“刷新”风格的网站(尽管版本非常慢),您必须不断地将数据从客户端来回传递到服务器,然后再返回到客户端渲染形式非常缓慢且效率低下。

    每次执行服务器端操作 (google.script.run...) 时,Google 的云服务器都必须加载应用程序状态、执行功能然后终止。

    我的建议(因为我正在开发一个需要一些模板的产品)是简单地使用客户端 javascript 来呈现和重新呈现你的 UI。

    我主要使用 jQuery,但与 KnockoutJS 等出色的 javascript 模板引擎相比,它非常冗长且耗时。

    如果任何 SO 用户找到了在 GAS 中制作响应式和交互式 UI 的更好方法,请告诉我们!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 2012-03-31
      相关资源
      最近更新 更多