Hi all,
Scenario: I have a nav bar and page content rendered under it.
I want the nav bar title to be changed from the rendered content under.
Nav bar:
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './nav-bar.html';
export const NavBarTitle = new ReactiveVar('Title');
Template.Nav_bar.helpers({
title: () => {
return NavBarTitle.get();
}
});
Example page rendered under
import { Template } from 'meteor/templating';
import NavBarTitle from '/imports/ui/components/nav-bar/nav-bar.js';
import './language-selection.html';
Template.Language_selection.onCreated(function () {
console.log(NavBarTitle);
NavBarTitle.set("Language selection");
});
the console.log part actually shows NavBarTitle as a ReactiveVar but with no methods on it…
and the Js error:
Exception in defer callback: TypeError: NavBarTitle.set is not a function
//EDIT: I also tried putting the code inside onRendered and inside events (a click event) -> I get the same error, and the same object in console.log
The documentation says that
// A store to use for the current language
export const CurrentLanguage = new ReactiveVar('en');
import CurrentLanguage from '../stores/current-language.js';
TAPi18n.setLanguage(() => {
CurrentLanguage.get();
});
I put curly braces around NavBarTitle like:
import { NavBarTitle } from '/imports/ui/components/nav-bar/nav-bar.js';
and it worked now. Someone please edit the misleading docs .
Another thread I answer myself…well hopefully it helps someone else too.
Yep, those docs are definitely wrong
The link to edit the docs are at the top and bottom of each article. Want to add a PR for that change now?
---
title: User Interfaces
description: General tips for structuring your UI code, independent of your view rendering technology.
discourseTopicId: 19665
---
After reading this guide, you'll know:
1. How to build reusable client side components in any user interface framework.
2. How to build a style guide to allow you to visually test such reusable components.
3. Patterns for building front end components in a performant way in Meteor.
4. How to build user interfaces in a maintainable and extensible way.
5. How to build components that can cope with a variety of different data sources.
6. How to use animation to keep users informed of changes.
<h2 id="view-layers">View layers</h2>
Meteor officially supports three user interface (UI) rendering libraries, [Blaze](blaze.html), [React](react.html) and [Angular](http://www.angular-meteor.com). Blaze was created as part of Meteor when it launched in 2011, React was created by Facebook in 2013, and Angular was created by Google in 2010. All three have been used successfully by large production apps. Blaze is the easiest to learn and has the most full-stack Meteor packages, but React and Angular are more developed and have larger communities.
This file has been truncated. show original
Sure
But if I need to sign that agreement thing then no.