javascript - Meteorjs有效显示管理面板

标签 javascript web meteor

我已经安装了陨石和路由器包

现在我有一个主页app.html

<body>
  <div class="container">
    <div class="page-header">
      <a href="/">
        <h1>Mi page</h1>
      </a>
    </div>
    <div class="content">
      {{renderPage}}
    </div>
  </div>
</body>

好的,现在所有页面都在 {{renderPage}} 中渲染。

现在用户转到/panel 并呈现用户面板,这是棘手的部分

此部分有一个 cpanel_nav_div 和一个 cpanel_body,我认为当用户保留在面板部分时,每次用户单击面板选项链接之一时 cpanel_nav_div 不会渲染,因此只有 cpanel_body 发生变化,这样效率更高。

最好的方法是什么??

它有一种方法可以执行其他路由器和过滤器路由,因此当路由匹配/panel/... 时,所有内容都会进入 cpanel_body 而不是进入 {{renderPage}} ???

设置 Session.get 和 Session.set 并根据 session 在 cpanel_body 内渲染内容(这样我们就错过了路由)

每次使用路由并渲染 cpanel_nav 和 cpanel_body ?

感谢您的帮助

最佳答案

您可以使用 preserve 告诉 Meteor 不要重新渲染模板的一部分。 :

You can "preserve" a DOM element during re-rendering, leaving the existing element in place in the document while replacing the surrounding HTML. This means that re-rendering a template need not disturb text fields, iframes, and other sensitive elements it contains. The elements to preserve must be present both as nodes in the old DOM and as tags in the new HTML. Meteor will patch the DOM around the preserved elements.

For example, to preserve all elements with ids in template 'foo', use:

 Template.foo.preserve({
   'input[id]': function (node) { return node.id; }
 });

因此,您可能希望使用preserve方法告诉M​​eteor不要重新渲染您的cpanel_nav_div元素。

关于javascript - Meteorjs有效显示管理面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13930569/

相关文章:

javascript - 如何从数组 Javascript/Jquery 中删除 obj

c# - 使用 URI 类时保持 url 编码

javascript - 在 Promise 回调中调用 Meteor 方法 [停止且没有错误]

javascript - 制作一个可以使用 top 属性进行动画切换的菜单

javascript - 通过 JsSIP 支持 WebRTC 互联网浏览器

url - 为什么http ://contain two slashes and file:///three in a browser navigation bar?

php - 从 Web 应用程序向 Android 发送数据/文本

css - 使用 bootstrap 时向 meteor 添加 body css 样式

css - 理解 CSS 类选择器在 meteor 中的使用

javascript - 如何向Toaster的onClick事件传递参数?