gridster.add_widget メソッドを使用して、レンダリング済みのテンプレートを DOM に渡そうとしています。
UI コマンドを呼び出すたびに一番下にエラー メッセージ メッセージが表示されるため、UI.renderWithData の使用方法を理解している必要はありません。
ドキュメントからの私の理解では、これらのコマンドは、渡されたテンプレートの完全に形成された HTML を返すということです。呼び出される「プロジェクト」ごとに赤いボックスを作成することで、gridster が正しく機能していることを確認しました。
どんな助けでも大歓迎です。ありがとう!
Template.projects.rendered = function(){
gridster = $(".gridster div").gridster({
widget_margins: [10, 10],
widget_base_dimensions: [140, 140]
}).data('gridster');
var projectz = Projects.find({}, {sort: { time: -1}});
$.each(projectz, function(index, widget){
if (widget != undefined) {
console.log(widget);
// This works and adds a red box for each project in the database
gridster.add_widget('<div style="background-color: red;">');
// This does NOT work, I assume it is an issue with my use of UI.renderWithData
// gridster.add_widget(UI.insert(UI.renderWithData(Template.projects, widget)), 1, 1);
}
});
};
//
// Error I get trying to gridster.add_widget() or console.log()
// with (UI.insert(UI.renderWithData(Template.projects, widget)));
//
Exception from Deps afterFlush function function: TypeError: Cannot read property 'nodeName' of undefined
at tbodyFixNeeded (http://localhost:3000/packages/ui.js?b523ef986d3d39671bcb40319d0df8982acacfe8:1368:13)
at Function.DomRange.insert (http://localhost:3000/packages/ui.js?b523ef986d3d39671bcb40319d0df8982acacfe8:1337:7)
at Object.UI.insert (http://localhost:3000/packages/ui.js?b523ef986d3d39671bcb40319d0df8982acacfe8:2123:15)
at null.<anonymous> (http://localhost:3000/client/controllers/projects.js?c493c07746d208ff23d7a134ed4353a706244d46:41:29)
at Function.o.extend.each (http://localhost:3000/client/compatability/jquery/jquery-2.1.0.min.js?4c694ca97ed11ffba659454ac63c35e0452a994d:2:2931)
at Object.Template.projects.rendered (http://localhost:3000/client/controllers/projects.js?c493c07746d208ff23d7a134ed4353a706244d46:37:7)
at http://localhost:3000/packages/ui.js?b523ef986d3d39671bcb40319d0df8982acacfe8:424:23
at _.extend.flush (http://localhost:3000/packages/deps.js?7afb832ce6e6c89421fa70dc066201f16f9b9105:331:13)