首页 > 解决方案 > 在 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);

在此处输入图像描述

标签: javascriptadaptive-cards

解决方案


通常流程是在单击按钮时禁用提交按钮(或添加加载掩码),然后将提交请求发送到后端。

当响应到来或请求失败时启用提交按钮(或删除加载掩码)。


推荐阅读