3

クライアント側のエラー (console.log エラー) が発生しますが、アプリは動作します (ユーザーを追加できます)

エラーは次のとおりです: Uncaught TypeError: Cannot read property '_liveui' of null

プロジェクトは私のリポジトリにあります: https://github.com/thiagofm/statusfyit

何が起こっている?

4

1 に答える 1

1

この質問が出されて以来、Meteor は API を大幅に更新したため、元のコードは直接実行されなくなりました。

jQuery.html を使用してテンプレートをレンダリングした結果を挿入するのは、通常の方法ではありません。handlebars テンプレート インクルード機能を使用することをお勧めします。

たとえば、次のように置き換えます。

$().ready(function(){
  hello = Meteor.ui.render(function(){
    return Template.hello();
  });
  $('body').html(hello);
});

と:

<body>
  {{> hello}}
</body>

アプリケーションの状態に応じて異なるものをレンダリングするには、'Session' オブジェクトを使用してインクルードを条件付けします。例えば:

<template name="foo">
  {{#if showNewUserDialog}}
    {{> newUserDialog}}
  {{else}}
    other stuff
  {{/if}}
</template>

<template name="newUserDialog">
  some stuff
</template>

Template.foo.showNewUserDialog = function () {
  return Session.get('showNewUserDialog');
};
Template.other.events({
  'click #new_user': function () {
     Session.set('showNewUserDialog', true);
  }
});
于 2012-12-14T00:51:34.987 に答える