Reputation: 3423
I have a button that should disappear upon clicking.
CardService.newAction().setFunctionName('submitForm');
var submitButton = CardService.newTextButton().setText('Yes')
.setOnClickAction(submitForm);
In submitForm() I want to hide/remove the button, How can I do that?
Thank you
Upvotes: 0
Views: 581
Reputation: 419
In the submitForm action callback, create a navigation with updateCard for the same card by passing a flag to hide the button. Follow the code below:
function getCard(hideBtn) {
var cb = CardService.newCardBuilder();
cb.setHeader(CardService.newCardHeader().setTitle("Card Header"));
var section = CardService.newCardSection();
if(!hideBtn) {
var submitForm = CardService.newAction().setFunctionName('submitForm');
var submitButton = CardService.newTextButton().setText('Yes').setOnClickAction(submitForm);
section.addWidget(submitButton);
}
cb.addSection(section);
return cb.build();
}
function submitForm(e) {
var navigation = CardService.newNavigation().updateCard(getCard(true));
return CardService.newActionResponseBuilder().setNavigation(navigation).build();
}
Upvotes: 1