我到处搜索我无法想出解决方案。我试图让此代码在每次用户单击“提交”时显示一个图表(该部分有效)。问题出现在用户点击提交不止一次。它多次显示图表。我如何让它删除最后一个图表并用新的图表更新它?
function doGet() {
var uiApp = UiApp.createApplication().setTitle("some title");
var grid = uiApp.createGrid(3, 2);
grid.setWidget(0, 0, uiApp.createLabel('Lablel 1'));
grid.setWidget(1, 0, uiApp.createLabel('Lablel 2'));
var panel = uiApp.createVerticalPanel();
panel.add(grid);
var button = uiApp.createButton('submit');
var handler = uiApp.createServerHandler('b');
handler.addCallbackElement(grid);
button.addClickHandler(handler);
panel.add(button);
uiApp.add(panel);
return uiApp;
}
function b(e) {
var app = UiApp.getActiveApplication();
//gets all my chart data
var chart = getchartdata()
//Add chart
app.add(chart)
var uiApp = UiApp.getActiveApplication();
uiApp.close();
return uiApp;
}