2016-06-16 41 views
0

我想在*的地方使用id = "utr_c"的輸入值。從上次起的第6行。如何使用車把內部的輸入值.hbs模板

怎麼可能車把模板文件中:

{{#each content}} 
    {{#if isOddLine}} 
    <tr id = {{utr_id}} role="row" class="oddLine"> 
    {{else}} 
    <tr id = {{utr_id}} role="row" class="evenLine"> 
    {{/if}} 
    <td class="data-display-field" style="text-align: left;"><strong>{{creation_date}}</strong></td> 
    <td class="data-display-field" style="text-align: right;"><strong>{{shipper_name}}</strong></td> 
    <td class="data-display-field" style="text-align: right;"><strong>{{amount.amount_with_penny}}</strong></td> 
    <td class="data-display-field" style="text-align: right;"> 
     <input type = "text" id="utr_c"> 
    </td> 
    <td class="data-display-field" style="text-align: right;"> 
    <form action="/disbursements/get_utr_code" method="post"> 
    <input type="hidden" name="utr_id" value="{{utr_id}}"> 
    <input type="hidden" name="shipper_name" value ="{{shipper_name}}"> 
    <input type="hidden" name="biller_id" value ="{{biller_id}}"> 
    <input type="hidden" name="utrc" value = * > 
    <input type="submit" value="Submit UTR" class="btn-style" style="float:right; line-height: 12px; padding: 5px 12px; margin-right: 6px; margin-top: 5px;"> 
    </form> 
    </td> 
    </tr>   
{{/each}} 
+0

爲什麼要複製同樣的問題?我在過去的兩天裏看到了同樣的問題3次! [here](http://stackoverflow.com/questions/37837450/taking-input-from-inside-handlebar-hbs-file),[here](http://stackoverflow.com/questions/37850038/taking-input -from-inside-handlebar-template-file-hbs)和[here](http://stackoverflow.com/questions/37861042/how-to-use-a-input-value-from-inside-handlebar-hbs-模板) –

+0

前兩個可能類似,但第三個是不同的。請在評論之前仔細查看。並且請嘗試對問題提供一些有用的解決方案,而不是做出不相關的評論。 – sb15

+0

你應該學會正確地設定問題。否則,您可能無法獲得任何解決方案 –

回答

0

嘗試.js文件:

.hbs

<input type="hidden" name="utrc" value = {{{test_name}}} >

.es6

Template({ 
    ... 
    test_name: `"${this.model.test_name}"` 
}); 

把手HTML轉義由{{表達式}}返回的值。如果您不想讓Handlebars逃離某個值,請使用「三重藏匿」{{{。

根據手把文檔http://handlebarsjs.com/expressions.html

Source of information