2013-07-25 55 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

很好,从流星文档应该没事一样, –