riot-js

Open full view…

riot-tag and pass JSON attrs

mazvv
Wed, 16 Nov 2016 10:15:03 GMT

Hi all. I want mount riot tag using riot-tag with json attrs For example: --- <dropdown-field choices="[{&#34;label&#34;: &#34;Test1&#34;, &#34;value&#34;: 0}, {&#34;label&#34;: &#34;Test2&#34;, &#34;value&#34;: 1}]" name="status"></dropdown-field> --- But this does not works. As this.opts i've got something like this: --- Object {choices: "[label, label value]", name: "status"} ---

agustinquintanilla
Wed, 16 Nov 2016 19:07:17 GMT

I think that your problem is the use of '{ }' characters inside the attributes, had you try to pass the data as a variable reference? --- var choicesData = [{someDataHere: '...'}, {}, {}]; --- ---html <dropdown-field choices="{choicesData}" name="status"></dropdown-field> ---

mazvv
Thu, 17 Nov 2016 06:49:20 GMT

Thank you for reply. But I try to use server side rendering from Python Mako templates. Something like --- drop_down_tag(choices=json.dumps(choices)) ---

agustinquintanilla
Thu, 17 Nov 2016 14:06:02 GMT

Hi again, on that case you maybe interested on change the default riot curly braces --- riot.settings.brackets = '${ }' riot.settings.brackets = '\{\{ }}' --- so, you it don't have incompatibilities with the json data

agustinquintanilla
Thu, 17 Nov 2016 14:18:08 GMT

I think that brackets aren't a solution ... maybe you can mount the tag with --- riot.mount('dom', 'tag-name', {your data here}) --- or get the mounted tag via: --- document.querySelector('dom-identifier')._tag --- and send the parameter to it

mazvv
Sun, 04 Dec 2016 14:42:52 GMT

thnx, as temporaly solution riot.settings.brackets = '${ }' works