2012-05-23 94 views
3

我收到客戶端錯誤(執行console.log的),但我的應用程序工作的特性「_liveui」(我可以添加用戶)無法讀取空

的錯誤是: 遺漏的類型錯誤:無法讀取空

該項目的特性 '_liveui' 在我的回購: https://github.com/thiagofm/statusfyit

這是怎麼回事?

+1

我遇到了類似的問題,這個bug會影響連接到一個模板 – denysonique

+0

我的火腿有同樣的問題的事件。 – zengr

回答

1

流星已經更新了API,因爲這個問題被問到了,所以原來的代碼不再直接運行。

使用jQuery.html插入渲染模板的結果不是常規方法。最好使用手柄模板包含功能。

例如,替換:

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

隨着:

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

爲了使這取決於應用程序的狀態不同的東西,用 '會話' 對象中來控制包括。例如:

<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); 
    } 
});