Aaron McCormack
Aaron McCormack

Reputation: 11

Trouble embedding hrefs with mustache

I am currently trying to generate a dynamic table of information for an html doc (keys and summaries) using mustache as the templating engine.

However my issue is embedding an href inside of the <a> tag for my key. The table generates dynamically, as the keys and summaries display correctly but the value of the href is the same for each of the keys and summaries(the first value). How do I make each key/summary have a different link/href? I have tried so many workarounds but cannot seem to find a solution when utilizing mustache. Is this possible when using mustache?

Any help is appreciated. My table code and JavaScript table are shown below.

 {{#records}}
  {{#jKey}}

  <tr class="c29">
    <td class = c105 colspan="1" rowspan="1"><span class="c55 c71 c130"><a class="c49" href="{{#jLink}}{{jL}}{{/jLink}}">{{jK}}</a></span></td>
    <td class="c98"></td>
    <td class="c114" ></td>
    <td class="c12">{{jSprint}}</td>
    <td class="c126"></td>
    {{/jKey}}
    {{/records}}
  </tr>
var Data = {
    "jKey": [
        {"jK": issues[0].key + ": " + issues[0].summary},
        {"jK": issues[1].key + ": " + issues[1].summary},
        {"jK": issues[2].key + ": " + issues[2].summary},
        {"jK": issues[3].key + ": " + issues[3].summary},
        {"jK": issues[4].key + ": " + issues[4].summary},
        {"jK": issues[5].key + ": " + issues[5].summary},
        {"jK": issues[6].key + ": " + issues[6].summary},
        {"jK": issues[7].key + ": " + issues[7].summary},
    ],
    "jLink": [
        {"jL": issues[0].link},
        {"jL": issues[1].link},
        {"jL": issues[2].link},
        {"jL": issues[3].link},
        {"jL": issues[4].link},
        {"jL": issues[5].link},
        {"jL": issues[6].link},
        {"jL": issues[7].link}
    ],
    "jSprint": versionName,
    "jTasks" : "array of info",
    "relDate": today,
    "cYear"  : yyyy
  };

Upvotes: 1

Views: 56

Answers (1)

Aaron McCormack
Aaron McCormack

Reputation: 11

I've managed to get each href to be unique now, my Data structure was changed so that each "jK": issues[0].key + ": " + issues[0].summary also has an accompanying link in that part of the Data like this:

"jK": issues[0].key + ":  " + issues[0].summary, "jL":issues[0].link

So now when the table is generated each of the links embedded in the key and summary bring you to a different page.

Upvotes: 0

Related Questions