Dart template, and {{}} placeholder in on-click

Issue

I am experimenting with various ways to create a HTML5 table from data using Dart. I have the following:

<table id="sitelist">
  <thead>
    <tr><th>Select a site</th>
      </tr>
    </thead>
  <tbody template iterate="x in siteCells">
    <tr on-click="displaySite('{{x[0]}}')"> <td> {{x[1]}} </td>
      </tr> 
    </tbody>
  </table>

The idea is to have one on click handler which takes the site id as a parameter. but the parameter to displaySite is not set correctly – this function receives the literal string {{x[1]}}.
The site name x[1] is displayed correctly.

So my question is: Is it possible to have {{}} substitution work inside the parameter list of the on click handler?

Solution

Simply remove the {{ }} from the displaySite() call in on-click, and it will work.

<table id="sitelist">
  <thead>
    <tr><th>Select a site</th>
    </tr>
  </thead>
  <tbody template iterate="x in siteCells">
    <tr on-click="displaySite(x[0])"> <td> {{x[1]}} </td>
    </tr>
  </tbody>
</table>

Hope that helps!

Answered By – Seth Ladd

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *