![](/img/trans.png)
[英]Google Apps Script google.script.run.withSuccessHandler failing
[英]how to combine google app script processForm, withSuccessHandler and withUserObject
所以我在这里关注文档:
https://developers.google.com/apps-script/html_service?hl=zh_CN#GoogleScriptAPI
似乎我应该能够在同一位置使用processForm,withSuccessHandler和withUserObject,但目前无法使它正常工作。 这是一次尝试
<input name='submission'>
<input type='hidden' name='match' value ='<?= match?>'>
<input type='hidden' name='week' value ='<?= j?>'>
<input type='hidden' name='assignment' value ='<?= i?>'>
<input id='button' type='button' onclick='google.script.run.processForm(this.parentNode).withSuccessHandler(submissionReceived).withUserObject(this).getCurrentDate()'>
但这在单击按钮时给我以下错误:
无法读取未定义的属性“ withSuccessHandler_m___”
以下工作正常:
google.script.run.withSuccessHandler(submissionReceived).processForm(this.parentNode)
但是,我希望“ submissionReceived”函数接收本地对象,以便我可以进行一些本地更改以反映该特定按钮(很多)已被单击的事实。 基本上这个顺序:
google.script.run.processForm(this.parentNode).withSuccessHandler(submissionReceived)
失败,并显示相同的“无法读取未定义的属性'withSuccessHandler_m___'”错误,无论我是否尝试将对象传递给submittReceived
将运行以下命令:
google.script.run.withSuccessHandler(submissionReceived).withUserObject(this).processForm(this.parentNode)
但是传递给submittingReceived的单个参数是未定义的
关于如何成功组合这三个功能以便在单击按钮时将对象传递给客户端javascript功能的任何想法?
我设法使它与以下对象一起使用:
var r = google.script.run.withSuccessHandler(submissionReceived).withUserObject(this);r.processForm(this.parentNode);
似乎需要先设置成功处理程序。 还要注意,这会将两个参数传递给submittingReceived函数,其中第一个是未定义的,而第二个是当前的本地对象,因此函数定义如下所示:
function submissionReceived(a,input) {
其中a是未定义的,而input是与脚本在其中运行的input标签相对应的dom节点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.