【发布时间】:2016-01-25 20:44:06
【问题描述】:
我的表单有文档列表、一个输入字段和按钮。
情景:
- 我在输入字段中输入产品名称。
- 我点击搜索按钮
- 呈现具有该名称的文档,但输入字段被重置(变为空白)
如何防止渲染功能重置输入字段? 这是我的代码的一部分:
观点
View.DocumentsView = Marionette.CompositeView.extend({
events : {
"click button.js-Doc-search": "search",
},
initialize: function() {
this.collection = this.model.get("list");
},
onRender : function(){
// Do something to prevent the reset of the input
}
});
控制者
documentsView.on("documents:search", function(name) {
var that = this;
var fetchingDocuments = this.request("document:entities", name);
$.when(fetchingDocuments).done(function(documents) {
that.model = documents;
that.collection = documents.get("list");
that.render();
});
});
【问题讨论】:
-
不清楚输入字段为何变为空白。我的猜测是
search方法中的某些内容可以清除它。可以分享一下 DocumentView 的search方法吗?
标签: jquery backbone.js render marionette reset