谷歌脚本无法更新网页 [英] google script unable to update web page

查看:98
本文介绍了谷歌脚本无法更新网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我创建网页/应用并显示列表的片段。然后点击列表中的项目我想用另一个列表替换列表。我尝试使用垂直面板作为根容器并清除并添加列表。即使新列表的处理程序执行正常后,该网页仍显示旧列表。

  // user_list函数更新垂直面板,但网页仍然显示旧的rep_list 
函数doGet(e){
if(e == null || e.parameter.dvid == null){
return rep_list();



函数user_list(路径){

var app = UiApp.getActiveApplication()。setTitle(List Folders);

var content = app.getElementById('root');

content.clear();
var list = app.createListBox();
//填充列表

content.add(list);
返回应用程序;


$ b函数rep_list(){

var app = UiApp.createApplication()。setTitle(List Repositories);

var content = app.createVerticalPanel()。setId('root');
var list = app.createListBox(true).setId('repoList')。setName('repo');
var handler = app.createServerHandler(listFolders);
list.addClickHandler(处理程序)

//填充列表

content.add(list);

app.add(content);
返回应用程序;

}

函数列表文件夹(e){
var repo = e.parameter.repo;
user_list(repo);
}

问候,

Miten。

解决方案

您的 listFolders()一个新的UI实例。尝试:

 函数listFolders(e){
var repo = e.parameter.repo;
var app = user_list(repo);
返回应用程序;
}


Below is snippet where I create a web page / app and show a list. Then on click of item in list I want to replace the list with another list. I try it by using vertical panel as root container and clearing and adding list to it. The web page though keeps showing old list even after handler for new list executes fine.

//user_list function updates vertical panel but the web page still shows old rep_list
 function doGet(e) {
   if(e == null || e.parameter.dvid == null) {
     return rep_list();
   }  
 }

function user_list(path) {

  var app = UiApp.getActiveApplication().setTitle("List Folders");

  var content = app.getElementById('root');

  content.clear();
  var list = app.createListBox();
  //populate list  

  content.add(list);
  return app;

}

function rep_list () {

  var app = UiApp.createApplication().setTitle("List Repositories");

  var content = app.createVerticalPanel().setId('root');
  var list = app.createListBox(true).setId('repoList').setName('repo');
  var handler = app.createServerHandler("listFolders");
  list.addClickHandler(handler)

  //populate list

  content.add(list);

  app.add(content);
  return app;

}

function listFolders(e){
  var repo = e.parameter.repo;
  user_list(repo);
}

Regards,

Miten.

解决方案

Your listFolders() function isn't returning a new UI instance. Try:

function listFolders(e){
  var repo = e.parameter.repo;
  var app = user_list(repo);
  return app;
}

这篇关于谷歌脚本无法更新网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆