当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Failed due to illegal value in property: context

问题描述:

I have a google apps script using jquery,jquery-ui and jquery-mobile. The html is a simple form with a button:

<input type="button" value="Submit"

onclick="google.script.run

.withSuccessHandler(updateOutput)

.processForm($('#form'))" />

When I load as web app and click on the button I get:

3359132324-mae_html_user_bin_i18n_mae_html_user.js:13 Uncaught TypeError: Failed due to illegal value in property: context

The code is obfuscated and I can't make sense out of it. I tried to use Logger.log in processForm, nothing appears in View -> Logs. Execution transcript is:

[14-12-25 17:06:15:613 IST] Starting execution

[14-12-25 17:06:15:649 IST] Execution succeeded [0.0 seconds total runtime]

If I set a breakpoint, the script doesn't stop there (I guess this is because it is deployed as a web app, can I change that?)

网友答案:

The processForm() method is expecting a native HTMLElement argument, not a jQuery context.

Try this:

<input type="button" value="Submit"
  onclick="google.script.run
      .withSuccessHandler(updateOutput)
      .processForm($('#form').get(0))" />

See jQuery get()

分享给朋友:
您可能感兴趣的文章:
随机阅读: