0
在underscore.js模板中,是否有方法從點擊事件中獲取模板的數據?例如:下劃線/骨幹模板事件
geocoder.geocode({
'address' : $(this.el).find("input[name=locationSearchText]").val()
}, function(results, status) {
if (results && status && status == 'OK') {
this.results = results;
var list =_.template("<ul><% _.each(results, function(result){ %><li><%= result.formatted_address %></li><% })%></ul>");
$el.find("#search-results").html(list);
}else{
alert("SOMETHING WENT WRONG!");
}
});
然後在視圖骨幹:
events: {
'click #search-results li': function(data){ 'the data of the `result` that was passed to the template in the each'}
},
你只是打敗了我...雖然我沒有肉體出去。 – Jack