This forum has moved to a new location and is in read-only mode. Please visit to access the new location.


When using external javascript files within components what is the best method to pass data to a javascript file? Assuming components can be used multiple times on a single page I can't really use static IDs to target a specific element.

I guess I can use something like this and in my javascript run a for loop(?) to pass settings and data but it feels kind of hacky.

    window.components['{{ }}'] = {
        id: '{{ }}',
        foo: [
            '{{ bar }}',
            '{{ baz }}'

And actually I'm not entirely sure, do css/js files get injected once or for each component instance?


the .htm file

<div class="custom-component"  data-title="the title" >

the .js file

 $('.custom-component').each(function ()
        var $element = $(this);
        var title = $'title');
        console.log("title =" +title );

so you can replace "the title" by {{ }}

Last updated


Eventually I didn't need that, but thanks anyway

1-3 of 3

You cannot edit posts or make replies: the forum has moved to