Iron Router 2nd view inside a sidebar

I am trying to have a chatroom sidebar and I want users to be able to go to other chatrooms and return to the global chat in that sidebar. I have been using Meteoric and Iron Router and hope that I can find a solution using those packages.

Currently I am able to get this to work by using an iframe to load the the whole side bar and it treated it like a separate window. However, loading an entire second window doesn’t seem like a good idea and seems to be affecting the ability to click on textarea.

I was wondering if anyone has tried done something like this? Or something similar to an iframe inside another template with iron router.

This is how I would do it.

  • The sidebar should just be a simple blaze template.
  • The sidebar template should have a helper the returns a value of a session.get(sidebarvalues).
  • The sidebar should display the data as links. So that once the user clicks an item, it would change the url and url would dictate what appears in the {{yield}}.
  • The sidebar values can be populated with content on the onRender of the sidebar template, either by a direct collection query or meteor call, the result of the callback should be stored in sessions.set(sidebarvalues).

There are better ways to do this. But i think this is one way to do it with blaze. I also think this is better than an iframe.

You could put the sidebar in your layout and like @gilmichael said have {{>yield}} for the rest of the page. Would suggest storing the data in a collection instead of Session. In the sidebar template you want to do a subscribe/query for its data.

<template name="ApplicationLayout">

Thanks you for your responses. I forgot to mention this is an app. The issue that I am running into is that the app goes to a specific route when a link is clicked on. I want the sidebar to be open and only change the content inside that side bar without going to another page.

I used sessions to get the group id and change the messages shown. Thanks for your help.