在google app maker中,我正在向第三方供应商进行API调用,并且在加载数据时显示了一个微调框。数据加载后,如何以编程方式隐藏微调框?
客户端脚本
public function calculate_shipping($package = array())
{
// error_log(json_encode($this->_rates));
if (isset($this->_rates['shipping_standart']) && isset($this-
>_rates['shipping_standart']['cost'])) {
$rateData = array(
'id' => $this->id . '_s',
'label' => 'Standard',
'cost' => $this->_rates['shipping_standart']['cost'] /
100,
'calc_tax' => 'per_order'
);
$this->add_rate($rateData);
}
}
服务器脚本
google.script.run.withSuccessHandler(function(response){
groupRules= JSON.parse(response);
}).withFailureHandler(function(err){
console.error(err);
setNotificationText('Unable to retrieve group rules. Please try again.');
app.popups.snackbar.visible = true;
}).getGroupRules(groupId);
答案 0 :(得分:2)
您需要放置Spinner.visible = false;。在成功和失败处理程序中,以便App Maker等待脚本完成。
app.pages.NewPage.descendants.Spinner1.visible = true;
google.script.run.withSuccessHandler(function(response){
groupRules= JSON.parse(response);
app.pages.NewPage.descendants.Spinner1.visible = false;
}).withFailureHandler(function(err){
console.error(err);
setNotificationText('Unable to retrieve group rules. Please try again.');
app.popups.snackbar.visible = true;
app.pages.NewPage.descendants.Spinner1.visible = false;
}).getGroupRules(groupId);