Normally I would have included this via a custom formatter and chain it to an empty string
dmx.Formatter('string', 'userTimezone', function () {
return dayjs.tz.guess()
});
''.getTimezone()
But I though I would give custom components a try.
- Add Dayjs library(and plugins) to your page via CDN or locally.
<script src="https://unpkg.com/dayjs@1.10.4/dayjs.min.js"></script>
<script src="https://unpkg.com/dayjs@1.10.4/plugin/utc.js"></script>
<script src="https://unpkg.com/dayjs@1.10.4/plugin/timezone.js"></script>
- Add Custom Component code to your page via
script
tag
dmx.Component("dayjs", {
methods: {
getTimezone: function () {
return dayjs.tz.guess();
}
},
events: {},
render: function (t) {
dayjs.extend(window.dayjs_plugin_utc)
dayjs.extend(window.dayjs_plugin_timezone)
}
});
- Add html component
<dmx-dayjs id="dayjs1"></dmx-dayjs>
- Profit
<dmx-serverconnect id="weekly_steps" url="/api/fitness/getDataWeekly" onsuccess="renderChart()" dmx-param:tz="dayjs1.getTimezone()"></dmx-serverconnect>
Sure this component can be improved with additional methods, events and plugin extension only when needed.
Community Page
Last updated:
Last updated: