回答
通常,您可以在視圖上使用tagName屬性來生成該類型的html元素。將tagName設置爲「li」或「table」或任何可以在您的html中生成外部標記而不是「div」的內容。
然而,從生成的html的外觀來看,您的模板似乎可能存在一些錯誤。木偶不應該生成額外的「div」,當然不是空白的「」。
你認爲它可能是由jQueryUI生成的嗎?你可以看到我使用jQuery對話框。我用TypeScript和Dust開發它。 – WangHongjian
快速瀏覽一下使用TypeScript和Marionette的博客。此博客使用Marionette模板引擎,而不是灰塵 - 因此它可能與粉塵有關。 http://blorkfish.wordpress.com/2014/03/22/typescript-using-backbone-marionette-and-rest-webapi-part-1/ – blorkfish
調試完所有相關資源後,我發現這個問題是由dustjs(文件名爲backbone.marionette.dust.js)引起的。
Backbone.Marionette.Renderer.render = function (template, data) {
var html;
// Template must be compiled and in the dust cache. Recommend pre-compiling
// and loading the templates as scripts at app start.
dust.render(template, data, function (err, out) {
html = out;
});
html = html.trim();//This line was added by me.
return html;
};
在該行'html = html.trim();'後面不會出現空的文本節點。加入。
- 1. 如何避免空值在文本框
- 2. 我如何避免生成一個空的報告文件
- 3. 如何避免爲Hive查詢生成空的.deflate文件?
- 4. 如何避免來自節點的多個文本值
- 5. 如何避免在XSLT中生成空屬性?
- 6. 甲骨文的Xml生成節點空
- 7. XSLT如何避免選擇節點
- 8. 如何避免在TFS 2012中生成(或刪除)PDB文件生成結果
- 9. 如何避免產生在bash腳本中間文件
- 10. 避免在子節點中剝去空白
- 11. 如何避免被生成圖像
- 12. 掩碼文本框中的空間如何避免
- 13. 如何避免在VS2008中的點
- 14. 如何在使用nuget包時避免生成xml文檔
- 15. 如何避免使用FOR XML PATH的子節點中的命名空間?
- 16. 如何避免在C#中獲得空
- 17. 如何避免在Android中發生ANR?
- 18. 避免重複生成ID
- 19. 如何避免情節中的空因素水平?
- 20. 如何在名稱空間中生成soap4r wsdl2ruby類以避免名稱衝突?
- 21. 如何避免在派生類中實現空構造函數?
- 22. 當我的XML文件中不存在節點時,如何避免NullReferenceExceptions?
- 23. xtext代碼生成,如何避免代碼生成一行?
- 24. 帶節點的jsdoc生成空的index.html
- 25. 如何避免View.getDrawingCache()中的空指針?
- 26. 如何避免java.lang.OutOfMemoryError:Netbeans中的PermGen空間
- 27. 如何避免mysqli_fetch_assoc中的空值?
- 28. 如何避免在javasccript中爲許多變量生成函數?
- 29. 如何在Xtext中生成方法時避免JvmParameterizedTypeReference:java.util.List <JvmUnknownTypeReference:A>?
- 30. 如何下載節點[節點]生成Excel文件[角]
看起來像您的模板引擎呈現空值,例如null或undefined。如果它是一個數組,請使用_.compact()首先刪除空元素。 –