我无法设法处理'check-box handler'这个问题,我已经追溯到if-control函数中。 如果您尝试以下修改后的代码,您会看到布尔变量“e.parameter.myCheckBox”产生正确的结果,但是,基于此变量的if-branching-off不起作用。有没有人在这看到错误?
非常感谢你 马丁
function ifTest(e) {
var app = UiApp.createApplication().setTitle('ifTest');
var panel = app.createVerticalPanel();
var grid = app.createGrid(3, 3);
var myCheckBox = app.createCheckBox().setName('myCheckBox').setId('myCheckBox');
var button = app.createButton('submit').setId("submit").setWidth("280").setHeight("35");
grid.setWidget(1, 0, app.createLabel('Check for True').setStyleAttribute("font-size", "110%"));
grid.setWidget(1, 1, myCheckBox);
grid.setWidget(2, 1, button);
var handler = app.createServerHandler('ifCheck');
var handler = app.createServerClickHandler('ifCheck');
handler.addCallbackElement(myCheckBox);
myCheckBox.setValue(false, false);
handler.addCallbackElement(grid);
button.addClickHandler(handler);
panel.add(grid);
app.add(panel);
ss.show(app);
return app;
}
function ifCheck(e) {
var bCBresult = e.parameter.myCheckBox;
var app = UiApp.getActiveApplication();
Browser.msgBox(bCBresult);
if (bCBresult) {
Browser.msgBox("bCBresult = true");
}
else {
Browser.msgBox("bCBresult = false");
};
return app.close();
}
答案 0 :(得分:0)
e.parameter.myCheckBox
返回的值是一个字符串,而不是布尔值。 (实际上,所有e.parameter值都是这种情况......,它们总是字符串)
所以你的情况是if (bCBresult=='true') {