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