<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css">最初に、このようなCSSのリンク用タグが用意されていますね。これはGoogleが用意するアドオン用のCSSです。これを読み込んで利用することで、アドオンらしいルック&フィールを得ることができます。
google.script.runなんだかわかりにくいですが、google.script.runの後にメソッドチェーンでいくつもの処理を続けて書いているということはわかるでしょう。これらは整理するとこうなります。
.withSuccessHandler(……成功時の処理……)
.withFailureHandler(……失敗時の処理……)
.withUserObject(……受け渡すオブジェクト……)
.呼び出す関数(引数);
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css">
<h1>サンプルAdd-on</h1>
<div>
<p>あなたの名前:</p>
<div><input type="text" id="mysidebar_intput1" />
<button onclick="doAction(event);" class="action">Click</button></div>
</div>
<script>
function doAction(e) {
var str = document.querySelector('#mysidebar_intput1').value;
google.script.run
.withSuccessHandler(
function(msg, element) {})
.withFailureHandler(
function(msg, element) {})
.withUserObject(this)
.hello(str);
}
</script>
| << 前へ | 次へ >> |