【发布时间】:2011-06-18 00:53:02
【问题描述】:
我使用 Rails3 作为我的后端并 Jammit 到资产...现在我试图不压缩甚至打包资产。
简单事件没有运行,但 alert('asd') int inialize 正在按预期工作。
我也已经在其他对象中尝试过其他类型的事件,但没有成功。
我的代码如下:
var InvoiceStock = Backbone.View.extend({
initialize: function(args) {
_.bindAll(this, 'find_product', 'product_added');
this.products = new ProductCollection();
this.products.bind('add', this.product_added);
alert('asd');
},
events: {
"keypress #product_finder": "find_product"
},
find_product: function(e) {
alert('teste');
},
product_added: function(product) {
alert('pqp4');
}
});
还有我的 RUBY HTML:
<%= text_field 'search', :isbn_or_isbn10_or_publisher_or_authors_or_name_like, :id => 'product_finder' %> ou
<%= link_to 'criar um produto', '', :id => 'new_product_link' %>.
生成这个:
<label>Adicionar</label>
<input id="product_finder" class="ui-autocomplete-input" type="text" size="30" name="search[isbn_or_isbn10_or_publisher_or_authors_or_name_like]" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
ou
<a id="new_product_link" href="">criar um produto</a>
【问题讨论】:
标签: javascript javascript-events backbone.js