0
我的要求是我需要向用戶顯示一組選項。我用鬍子模板來渲染使用CanJS javascript框架的選項。HTML標籤在CanJS中用鬍子模板轉義
這裏的問題是,當我試圖呈現如下選項: 土豆盧比。 12
小鬍子模板正在逃離我的HTML,它正在顯示帶有HTML標籤的值。
我在我的模板中也使用了{{{}}},但它沒有幫助。
請檢查相同的小提琴。
http://jsfiddle.net/arvi87/22CU8/1/
我的鬍鬚模板:
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{{display}}}</option>
{{/options}}
我的採樣控制我在哪裏數據綁定到我的模板:
var frag = can.view('{{' +this.options.view+ '}}',{
/*
I am passing observe here which is escaping the HTML tags like:
Cabbage <span>Price: Rs.12</span>
*/
options: arrayObserver
/*
This is rendering properly. Not sure about what is the difference ?
Cabbage Price: Rs.12
*/
//options: array
});
我選擇陣列:
var array = [{
selected: true,
display: "None"
},{
selected: false,
display: "Tomato"
},{
selected: false,
display: "Potato <span>Rs.10</span>"
},{
selected: false,
display: 'Cabbage <span>Price: Rs.12</span>'
}];
arrayObserver = new can.Observe.List(array);
任何幫助都會很棒。
謝謝。
感謝您的信息。將嘗試與幫手。 – Aravind