Onclick Events

I have a simple card with a Table on it where one column that has a HTML link created with a concat function. The link is to call an Azure API and I'm trying to modify the link so that it will call the API silently instead of opening a new tab each time.

I was able to play with an HTML brick and get a Javascript onclick method that worked, but when I tried to migrate that to the card it didn't do anything. It appeared to me that the "onclick" event was simply being ignored, so I simplified it to the following and confirmed that the onclick event is not firing:

concat('<a href="#" onclick="console.log(''test'');">Click Me</a>')

When I click on it, the card tries to filter instead of triggering the console log.

Am I doing something wrong, or is the onclick event ignored in this context?

Best Answer

  • ArborRose
    ArborRose Coach
    edited October 3 Answer ✓

    The behavior you're encountering happens because Domo cards are designed to handle data and interactivity in the form of filters rather than custom JavaScript events like onclick. Custom HTML or JavaScript is often sanitized or blocked for security reasons.

    Bricks are your best bet for custom scripts, but if you want to call the Azure API on user interaction, consider using Action Buttons or developing a custom app to achieve this.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Answers

  • ArborRose
    ArborRose Coach
    edited October 3 Answer ✓

    The behavior you're encountering happens because Domo cards are designed to handle data and interactivity in the form of filters rather than custom JavaScript events like onclick. Custom HTML or JavaScript is often sanitized or blocked for security reasons.

    Bricks are your best bet for custom scripts, but if you want to call the Azure API on user interaction, consider using Action Buttons or developing a custom app to achieve this.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • For reference here's a list of things that are supported in an HTML table. JavaScript isn't supported.

    https://domo-support.domo.com/s/article/360043430033?language=en_US#HTMLTableTags

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • pwtm
    pwtm Member

    Thanks to you both for the response. It seems my options are at least narrowing. I'm still learning Domo so I'm not familiar with Action Buttons. I'll look into those. It seems like that may be my last option. I'm not sure where to start with creating a custom application like this.

  • pwtm
    pwtm Member

    I just tried an HTML table with the onclick event to write the console log and it worked!