URL dynamic attribute for JSON Data Source

Would it be possible(and make sense) to add a dmx-bind for the url in the JSON Data Source.

I want to load json files depending on data bindings.

In my case language browser or url parameter. Related to i18n.

Sure we can add that, to use it already just use dmx-bind:url with expression like:

<div is="dmx-browser" id="browser1"></div>
<dmx-json-datasource id="jsonDS1" is="dmx-serverconnect" 
    dmx-bind:url="lang-{{browser1.language}}.js">
</dmx-json-datasource>

I tried that before opening the feature request. Doesn’t seem to work unfortunately.

Not the browser language value but the dmx-bind:url altogether.

I tried without the browser component to test it.

<dmx-json-datasource id="trans" is="dmx-serverconnect" dmx-bind:url="../../assets/locales/en-US/register.json"></dmx-json-datasource>

The url attribute doesn’t get set.

When you bind an attribute - it has to be an expression. So if you are entering a static string - enclose it in single quotes.

1 Like

Oh shit. That was a stupid mistake. As I tried with double quotes on the first attempt I didn’t add the single ones later on. Indeed it works.

As far as this request goes it’s now very low priority for me :slight_smile: I just thought there was an issue or a missing feature with the bind for this component. If it works in code it’s ok for me.

Thanks George!

1 Like