Bootstrap Modal Dialog 内のコレクションから取得した値を表示しようとすると、この問題が発生します。
これは、クライアント側の JavaScript のコードです。
Template.Modal_edit_client.edit_client_name = function() {
var c = Clients.findOne({_id: Session.get("current_editing")});
return c.name;
};
これはテンプレートです:
<template name="Modal_edit_client">
<div id="Modal_edit_client" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Editar cliente</h3>
</div>
<div class="modal-body">
<form id="edit_client" action="">
<fieldset>
<input id="edit_client_name" placeholder="Nombre y apellido" type="text" value="{{edit_client_name}}">
{{edit_client_name}}
</fieldset>
</form>
</div>
<div class="modal-footer">
<a id="edit_client_cancel" href="#" class="btn">Cancelar</a>
<a id="edit_client_save" href="#" class="btn btn-primary">Guardar</a>
</div>
</div>
</template>
ページはレンダリングされませんでした。コンソールは次のように表示されます。
Uncaught TypeError: Cannot read property 'name' of undefined
Exception from Meteor.flush: TypeError: Cannot call method 'firstNode' of undefined
at Object.Spark.renderToRange (http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:545:25)
at http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:860:13
at http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:31
at _.extend.run (http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:19:20)
at rerun (http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:71:15
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore/underscore.js?017a0dea6ebb07eec57a1541a0fd524665e769bd:79:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:69:13
at Array.forEach (native) logging.js:30
Exception from Meteor.flush: TypeError: Cannot call method 'firstNode' of undefined
at Object.Spark.renderToRange (http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:545:25)
at http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:860:13
at http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:31
at _.extend.run (http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:19:20)
at rerun (http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:71:15
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore/underscore.js?017a0dea6ebb07eec57a1541a0fd524665e769bd:79:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:69:13
at Array.forEach (native) logging.js:30
Exception from Meteor.flush: TypeError: Cannot call method 'firstNode' of undefined
at Object.Spark.renderToRange (http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:545:25)
at http://localhost:3000/packages/spark/spark.js?ba288278f8e36e3529187cea4590001f50ef0f95:860:13
at http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:31
at _.extend.run (http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:19:20)
at rerun (http://localhost:3000/packages/deps/deps-utils.js?0c00e493224f891c3d6c82a23693ba55e0f47611:78:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:71:15
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore/underscore.js?017a0dea6ebb07eec57a1541a0fd524665e769bd:79:11)
at http://localhost:3000/packages/deps/deps.js?d804638a4633c2f6488827923ba5fbd00f07d518:69:13
at Array.forEach (native)
問題は最初の行にあると思いますUncaught TypeError: Cannot read property 'name' of undefined
. c.name !== undefined
その後、amd がテンプレートをレンダリングするまで待つ方法はあり ますか?