I'm attempting to render an Adaptive Card via the Javascript SDK. I have attempted multiple versions of the SDK and used various samples from the Samples library on the Adaptive Cards official site.
In all cases, my code renders a:
<div class="ac-container ac-adaptiveCard" tabindex="0" style="display: flex; flex-direction: column; justify-content: flex-start; box-sizing: border-box; flex: 0 0 auto; padding: 15px; margin: 0px;"></div>
I am using the boilerplate example code from the documentation.
var adaptiveCard = new AdaptiveCards.AdaptiveCard();
adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
fontFamily: "Segoe UI, Helvetica Neue, sans-serif"
});
adaptiveCard.onExecuteAction = function (action) { alert("Ow!"); }
// Parse the card payload
adaptiveCard.parse(card);
// Render the card to an HTML element:
var renderedCard = adaptiveCard.render();
console.log("Adaptive Card Rendered: " + renderedCard.outerHTML);
var target = FifthMethod.Forms.Controls.AdaptiveCard._getInstance(objInfo.CurrentControlId);
target.appendChild(renderedCard);
I figured out that in my code I was receiving the adaptive card definition as a string. I had to use JSON.parse() to convert the string into a Javascript object. Once I did that, the issue resolved.