2013-07-25 101 views
0

是否可以通過流星會話更改div容器中的html代碼?如何通過流星會話更改div中的html代碼?

我的HTML代碼是

<template name="frame"> 
    <div class="container-fluid"> 
    {{html}} 
    </div> 
</div> 
</template> 

我的js文件看起來像這樣

Template.frame.html = function() { 
if (Session.equals('current_frame', 1)) 
    return "Verwaltung"; 
else if (Session.equals('current_frame', 2)) 
    return "Protokoll"; 
else if (Session.equals('current_frame', 3)) 
    return "Informationen"; 
else { 
    return ""; 
} 
}; 
Template.menu.events({ 
'tap, click .verwaltung':function(e,t) { 
    Session.set('current_frame', 1); 
}, 
'tap, click .protokoll':function(e,t){ 
    Session.set('current_frame', 2); 
}, 
'tap, click .informationen':function(e,t){ 
    Session.set('current_frame', 3); 
} 
}); 

我想改變{{HTML}}與根據會話不同的HTML代碼值。 這可能嗎?我怎麼能做到這一點?

我使用meteor和bootstrap。

乾杯!

回答

1

我在代碼中看到的唯一問題是menu.events。對於多個事件,你需要指定哪個元素將得到它separatelly

Template.menu.events({ 
    'tap .vermaltung, click .verwaltung': function() { 
    Session.set('current_frame', 1); 
    } 
} 
+0

很好,從流星文檔應該沒事一樣, –