我试图让背景按钮颜色从石灰绿变回原来的颜色。目前我已经获得了一种方法来实现这一点,但似乎必须有一种更有效的方法来做到这一点。
function doGet(e) {
var app = UiApp.createApplication();
var productInfoButton = app.createButton("Products").setId('productInfoButton');
var handlerL = app.createServerClickHandler('prodCompleteHandlerL');
var productCompleteCheckBox = app.createCheckBox().setId("productCompleteCheckBox")
.setName("productCompleteCheckBox");
productCompleteCheckBox.addClickHandler(handlerL);
handlerL.addCallbackElement(productInfoButton);
app.add(productInfoButton);
app.add(productCompleteCheckBox);
return app;
}
function prodCompleteHandlerL(e) {
var app = UiApp.getActiveApplication();
if(e.parameter.productCompleteCheckBox == 'true'){
app.getElementById('productInfoButton').setStyleAttribute('background', 'lime')
}else{
app.getElementById('productInfoButton').setStyleAttribute('background', 'url("https://dl.dropbox.com/u/211279/hborder.png") repeat-x 0px -27px')
}
return app;
}