弹出窗体中的消息框

时间:2014-09-17 18:50:50

标签: google-apps-script

我怀疑, 我为提交表单制作了一个按钮,当我按下第一个按钮时,向我显示确认是否继续的消息,但是当我按“否”并且消息消失并返回到表单时,但第一个按钮不起作用更多。

你知道我做错了。 谢谢大家。

function doGet(){
  var app = UiApp.createApplication().setTitle('Request Form');
  var flow = app.createFlowPanel().setStyleAttribute("textAlign", "center").setWidth("900px");  
  var buttons = app.createButton('Print and Save').setId('buttons');
  var handlers = app.createServerClickHandler('question').addCallbackElement(flow);
  buttons.addClickHandler(handlers);    
   flow.add(buttons);       
  app.add(flow);  
return app; 

}

function question(e){
var app = UiApp.getActiveApplication();    
var dialog = app.createPopupPanel().setModal(true).setSize(700, 100).setPopupPosition(10, 400);
var closeHandler = app.createClientHandler().forTargets(dialog).setVisible(false);
var handlersend = app.createServerClickHandler('Send');  
var handleract =app.createServerClickHandler('activateAgain');

var labelp  = app.createLabel('Are you sure that this information is correct?')
var buttonp1= app.createButton('yes, continue').addClickHandler(closeHandler).addClickHandler(handlersend);
var buttonp2= app.createButton('No, I want correct').addClickHandler(closeHandler).addClickHandler(handleract);
app.getElementById('buttons').setEnabled(false);

var gridp = app.createGrid(1,5);
        gridp.setWidget(0, 0, labelp)
      .setWidget(0,1,buttonp1)
      .setWidget(0,2,buttonp2);

dialog.add(gridp)
dialog.show();     
return app; 
}

function activateAgain(e){ 
var app = UiApp.getActiveApplication();   
app.getElementById('buttons').setEnabled(true);
return app;
}

function Send(e){
}

1 个答案:

答案 0 :(得分:0)

你试图在clientHandler中实现它,这基本上是一个好主意,但问题是clientHandler中没有一些方法,例如hide()不是!

所以你使用setVisible(false)来隐藏对话框,但是你不能再轻易看到它......

总而言之,我发现serverHandler和一些修改更容易。

由于你似乎对UiApp很满意,我不需要进一步解释,代码是自我解释的(我希望: - )

以下代码:(and test HERE

function doGet(){
  var app = UiApp.createApplication().setTitle('Request Form');
  var flow = app.createFlowPanel().setStyleAttribute("textAlign", "center").setWidth("900px");  
  var buttons = app.createButton('Print and Save').setId('buttons');
  var handlers = app.createServerClickHandler('question').addCallbackElement(flow);
  buttons.addClickHandler(handlers);    
   flow.add(buttons);       
  app.add(flow);  
return app; 

}

function question(e){
  var app = UiApp.getActiveApplication();    
  var dialog = app.createPopupPanel().setModal(true).setSize(700, 100).setPopupPosition(10, 400).setId('dialog');
  var button = app.getElementById('buttons').setEnabled(true);
  var closeHandler = app.createClientHandler().forTargets(button).setEnabled(true);
  var correctHandler = app.createServerHandler('hideDialog');
  var handlersend = app.createServerClickHandler('Send');    
  var labelp  = app.createLabel('Are you sure that this information is correct?')
  var buttonp1= app.createButton('yes, continue').addClickHandler(handlersend);
  var buttonp2= app.createButton('No, I want correct').addClickHandler(closeHandler).addClickHandler(correctHandler);
  app.getElementById('buttons').setEnabled(false);

  var gridp = app.createGrid(1,5);
  gridp.setWidget(0, 0, labelp)
      .setWidget(0,1,buttonp1)
  .setWidget(0,2,buttonp2);

  dialog.add(gridp)
  dialog.show();     
  return app; 
}

function hideDialog(){
  var app = UiApp.getActiveApplication();    
  var dialog = app.getElementById('dialog');
  dialog.hide();
  return app;
}

function Send(e){
  var app = UiApp.getActiveApplication();    
  var dialog = app.getElementById('dialog');
  dialog.hide();
  app.getElementById('buttons').setEnabled(false);
  app.add(app.createLabel('send'));
  return app;
}