流星应用集成



我有一个应用程序,其中有几个模板。我使用这些函数将这些模板调用到一个单页应用程序中,

$('#right2').replaceWith(Meteor.ui.chunk(Template.profile));

其中"'#right2'"是要替换的div 的 ID。 "Template.Profile"是替换模板。

发生的事情是,

当我在单击超链接时调用所有这些模板时,它们只被调用一次。当我再次调用这些模板时,它不起作用。

<li><a href="#" onclick = "renderMessage_Inbox();" ></a></li>

function renderMessage_Inbox(){       
alert("in messages");
$('#right2').replaceWith(Meteor.ui.chunk(Template.Message_Inbox));

}

模板:

<template name = "Message_Inbox">
<div id="right2">
<div class="floatLeft">
 <a href="Messages_Inbox.html"> <img src="/messagesText.png" alt="messages" class="floatLeft" /></a><span class="new floatLeft">1 NEW </span>
 </div> 
  <div align="center" class="floatRight" style="margin-bottom:20px">
<a href="#" class="button" onclick="ShowModalPopup('popupMessage'); return false;">
    <span>+ New Message</span>
</a>
</div>
  <div class="clear"></div>
  <div class="count" style="margin-bottom:10px"> 4 Messages</div>
  <!--start 1 messageBox-->
  <a href="#" onclick = "renderInbox_Details();" class="messageBox">
  <div class="left">
    <img src="/photo.jpg" style="margin-right:10px" class="floatLeft" />
    <p class="">Bill Brady</p>
    <p class="messageTitle" style="clear:none;">Title of the message</p>
    </div>
    <div class="floatRight">
     <p class="" align="right">X</p>
    <p class="messageTitle">March 12, 2012</p>
    </div>
   </a>
 </div> 
</template>

我有几个这样的调用函数和模板。但他们只被召唤一次。

您可以使用 $('#right2').html(Meteor.ui.chunk(Template.Message_Inbox));

它将解决您的问题。

最新更新