2014-09-17 8 views
1

У меня есть сомнение, Я делаю кнопку для отправки формы, и когда я нажимаю первую кнопку, мне появляется сообщение подтверждения о продолжении или нет, но когда я нажимаю «нет» и сообщение исчезают и возвращаются к форме, но первая кнопка больше не работает.Message Box во всплывающем окне

Вы знаете, что я ошибаюсь. благодарит всех.

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){ 
} 

ответ

0

Вы пытаетесь сделать это произойдет в ClientHandler, которая в основном хорошая идея, но проблема заключается в том, что некоторые методы не доступны в clientHandlers, например 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; 
} 
+0

Да спасибо. –

Смежные вопросы