所以我在这里关注文档:
https://developers.google.com/apps-script/html_service?hl=en#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___'”错误,无论我是否尝试将对象传递给submissionReceived
以下将运行:
google.script.run.withSuccessHandler(submissionReceived).withUserObject(this).processForm(this.parentNode)
但是传递给 submitReceived 的单个参数是未定义的
关于如何成功组合这三个函数以便在单击按钮时将对象传递给客户端 javascript 函数的任何想法?