我是Marionette.js的新手,当我重构现有的Backbone.js代码时,我注意到Marionette视图(itemview)上有两个回调类似于我,即onRender和onShow.使用它们有什么区别和更好的方法?
但是,查看源代码,我认为"render"和"show"事件都是在"view initialize"中引发的.
constructor: function(){
_.bindAll(this, "render");
var args = Array.prototype.slice.apply(arguments);
Backbone.View.prototype.constructor.apply(this, args);
Marionette.MonitorDOMRefresh(this);
this.listenTo(this, "show", this.onShowCalled, this);
}
Run Code Online (Sandbox Code Playgroud) 我最近从nuget更新了Lucene.net,DeleteDocuments停止了工作.以下代码与我正在做的类似...这是从"orchard cms"复制的.我注意到类似的问题,但解决方案与我的情况无关.有人遇到同样的问题吗?
public void Delete(string indexName, IEnumerable<int> documentIds) {
documentIds = documentIds.ToArray();
if (!documentIds.Any()) {
return;
}
using(var writer = new IndexWriter(indexName, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), false, IndexWriter.MaxFieldLength.UNLIMITED)) {
var query = new BooleanQuery();
try {
foreach (var id in documentIds) {
query.Add(new BooleanClause(new TermQuery(new Term("id", id.ToString(CultureInfo.InvariantCulture))), Occur.SHOULD));
}
writer.DeleteDocuments(query);
}
catch (Exception ex) {
Logger.Error(ex, "An unexpected error occured while removing the documents [{0}] from the index [{1}].", String.Join(", ", documentIds), indexName);
}
}
}
Run Code Online (Sandbox Code Playgroud)