Hi puja,
In your js action you are returning html string which you have to pass to widget that can handle html string , normal text label will treat this as plain text
ck editor you can download this ck editor module ,it comes with ck editor viewer , just pass your string to viewer, it will render as button.
Also for your requirement you don't need JavaScript to create button.
You can use a link button and give your url there directly.
Hope it helps!
try this and set return type of javascript action as nothing
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";
// BEGIN EXTRA CODE
// END EXTRA CODE
/**
* @param {string} wholeMessage
* @returns {Promise.<void>}
*/
export async function ChatMessageWithLink(wholeMessage) {
// BEGIN USER CODE
const button = document.createElement('button');
button.innerText = wholeMessage;
button.addEventListener('click', function() {
window.open(wholeMessage, '_blank');
});
// appending to the body
document.body.appendChild(button);
// END USER CODE
}
Hi Puja,
I have tried my code it works fine see below