Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handlebars and textarea

I am trying to learn handlebars for use in my MVC app. I have the following in my template:

<div class="control-group">
<label class="control-label" for="EmailHtml">Html:</label>
<div class="controls">          
<textarea id="EmailHtml" name="EmailHtml" cols="36" rows="5"/>          
</div>
</div>

And here is the JSON:

{"data":{"Results":[{"EmailHtml":"xyz"}],"Name":"Test Business"}}

After executing the above I see a TextArea with the correct width and height, but I don't see any data in it.

I also tried inserting the value="{{this.EmailHtml}}" but it still doesn't work.

How I get the textarea to be populated in my template?

like image 930
dotNetNewbie Avatar asked Dec 07 '25 13:12

dotNetNewbie


1 Answers

Shouldn't that be something more like:

<div class="control-group">
  <label class="control-label" for="EmailHtml">Html:</label>
  <div class="controls">          
    <textarea id="EmailHtml" name="EmailHtml" cols="36" rows="5">{{EmailHTML}}</textarea>          
  </div>
</div>

The value of a <textarea> is not in a value attribute, but resides between the tags. See: http://www.w3.org/TR/html401/interact/forms.html#h-17.7 , http://www.w3.org/TR/html-markup/textarea.html , among others.

like image 115
artlung Avatar answered Dec 10 '25 03:12

artlung