javascript - 在 JavaScript 自适应卡片中提交时禁用提交按钮/加载卡片
问题描述
我在提交卡片时有一个表单我希望禁用提交按钮或需要一种自适应卡片的加载以避免继续提交表单有人可以帮助我吗
卡片:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [{
"type": "TextBlock",
"text": "Hello !!",
"size": "Medium",
"weight": "Bolder"
},
{
"type": "Container",
"style": "accent",
"items": [{
"type": "TextBlock",
"text": "What was the type?"
},
{
"type": "Input.ChoiceSet",
"id": "call_type",
"style": "compact",
"isRequired": true,
"errorMessage": " required input",
"placeholder": "Please choose",
"choices": [{
"$data": "${Survey.questions[0].items}",
"title": "${choice}",
"value": "${value}"
}]
}
]
}
],
"actions": [{
"type": "Action.Submit",
"title": "Submit"
}]
}
和卡片渲染代码
var jsonTemplate = "some data",
var jsonDate = "some data"
var template = new ACData.Template(jsonTemplate);
var cardPayload = template.expand({
$root: jsonData
});
var adaptiveCard = new AdaptiveCards.AdaptiveCard();
adaptiveCard.onExecuteAction = function(action) {
alert("Ow!");
}
adaptiveCard.parse(cardPayload);
let renderedCard = adaptiveCard.render();
document.body.appendChild(renderedCard);
解决方案
通常流程是在单击按钮时禁用提交按钮(或添加加载掩码),然后将提交请求发送到后端。
当响应到来或请求失败时启用提交按钮(或删除加载掩码)。
推荐阅读
- amazon-web-services - 为什么我的 Springboot 部署到 EBS 不起作用?
- react-native - 不变违规:requireNativeComponent:在 UIManager 中找不到“AIRMap”。没有修复?
- data-warehouse - 初始化 Key FACT\DIM 表时如何保持参照完整性
- python - 简单的温度转换器
- python - 输入层的多个特征 Keras Python
- c++ - 合并排序的比较和排序部分有问题(c++)
- scala - 向 Akka HTTP HttpRequest 添加标头
- php - 在 Woocommerce 我的帐户订单表中更改视图按钮文本
- ruby-on-rails - 从同一模型中添加 2 个对导轨模型的引用
- swift - CoreMotion - 识别跳跃 (Swift)