mardi 16 juin 2015

Inserting Handlebars to the DOM in Ember

I am generating a list of checkboxes & radio buttons based on data coming from a server. The page is a Handlebars template using Ember. To generate my list on the page, I am using the following line of code:

document.getElementById('radioList').innerHTML = newHtml;

This works fine if newHtml is set to something like:

<li><input type="radio" id="radio1" name="radio /><label for="radio1">List item one</label></li>

However, I'd like events to be triggered based on these radio buttons (or checkboxes) being selected or unselected - and after some googling, it would seem using Handlebars helpers is the way to go. But when I try to insert the radio button using handlebars, with the newHtml set as such:

<li>{{input type="radio" id="radio1" name="radio }}<label for="radio1">List item one</label></li>

The text just appears rather than a radio button itself. Looking further into this seems to suggest that the Handlebars template I'm inserting into needs recompiled? I may be wrong, but I've spent quite a bit of time searching for answers to this problem and can't seem to find them. Any help would be appreciated!




Aucun commentaire:

Enregistrer un commentaire