question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make an HTML widget?

See original GitHub issue

It says “Can be literal HTML”. Given that, how would I insert a datasource?

<div style="background-color: gray">This is a timestamp: datasources["DS"]["Timestamp"]</div>

Related SO question: http://stackoverflow.com/questions/31592886/adding-literal-html-to-an-html-widget-with-data-from-a-datasource

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jritsemacommented, Jun 16, 2016

@Shamzic If you want to do dynamic html, I would recommend the handlebars plugin that allows you to have clean separation between your html and javascript (view/model) as well as tooling that allows you to do it outside of freeboard’s editor using your favorite dev tools.

0reactions
icandothat2commented, Mar 24, 2021

Yea this took me a while.

I think this is how the JS data source for the HTML widget works. Whatever you put in there is treated like a “closure”, so it just runs whatever code you put in there. Put “return” at the end and it will return a value out.

So, the trick is

1. Reference a datasource like:  var x = datasource['mysource']['data'];
2. build HTML as a string: var output = "<div style='color:blue'>"+x+"</div>";
3. return the html out like: return "output";
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 5: Creating Web Widget with HTML, CSS, and ...
Create a new HTML page and name it testpage.html and enter the code shown below. The widget code in the page contains few...
Read more >
Creating a widget - HTMLWidgets
We provide a name and type for the widget, plus a factory function that takes el (the HTML element that will host this...
Read more >
Creating HTML Widgets
Creating HTML Widgets · From the menu, click Digital Touchpoints > Digital Experience Portal > Widgets. · At the top-right corner of the...
Read more >
My First Real Project: Creating Widgets with Javascript, HTML ...
The project was to create a series of widgets with javascript, html and css. By definition, a widget is an application, or a...
Read more >
Build a HTML widget - Bloomreach Documentation
Build a HTML widget · Getting widget results · Request · Response · Response processing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found