These are chat archives for reactioncommerce/reaction

11th
Oct 2016
Hai Nguyen
@nguphoha
Oct 11 2016 04:10
@zenweasel I want to update DOM element of a template from another template, example, in some case, in the main template I want to update style class of header template. So how can I do that ?
Brent Hoover
@zenweasel
Oct 11 2016 05:49
@nguphoha that’s a good question. If you place your code in the onRendered I would think you could grab any DOM element that’s in the template space. I don’t think you are limited to just the current template
Spencer Norman
@spencern
Oct 11 2016 05:57
@nguphoha @zenweasel That doesn’t work in all circumstances, depends on the order that things render. Best bet is to stick a debugger call in the onRendered of the template that you’d like to do the modifying and see if the template you’d like to update is available.
Brent Hoover
@zenweasel
Oct 11 2016 05:58
@spencern if it’s the parent template, wouldn’t it always be available?
Spencer Norman
@spencern
Oct 11 2016 05:58
I’d say it should be, but I’m not certain that’s always true
Hai Nguyen
@nguphoha
Oct 11 2016 06:38
@zenweasel I tried to update, but It didnt work. I used jquery to get selector and add or remove stye class.
Hai Nguyen
@nguphoha
Oct 11 2016 07:19
@zenweasel How can I add title, description, keyword meta tags for each pages (each route)
Brent Hoover
@zenweasel
Oct 11 2016 07:22
there’s no way to add them at the route level yet, but you can look here to add them at the template level https://docs.reactioncommerce.com/reaction-docs/master/seo-metadata
Hai Nguyen
@nguphoha
Oct 11 2016 07:23
thanks brent
Jeremy Shimko
@jshimko
Oct 11 2016 12:51
You could use route hooks.
import { Router } from '/client/api';

Router.Hooks.onEnter('routeName', () => {
  // do stuff on that route
});
Jeremy Shimko
@jshimko
Oct 11 2016 12:57
Also, see the example for running a hook on all routes and using the context object to get route details on each route
function logSomeContext(context) {
  console.log("The current route details...");
  console.log("Params: ", context.params);
  console.log("Query Params: ", context.queryParams);
  console.log("Path: ", context.path);
  console.log("The route object: ", context.route);
}
// log out route details on every route
Router.Hooks.onEnter(logSomeContext);
Also note that Reaction uses kadira:dochead for managing meta tags. You should definitely use that API for setting ay meta tags that aren’t already set.
Frank Gutierrez
@dearfrankg
Oct 11 2016 20:40
@zenweasel what's up
Brent Hoover
@zenweasel
Oct 11 2016 20:41
me, just right now. It’s 4:45am
Spencer Norman
@spencern
Oct 11 2016 20:42
dude never sleeps
Frank Gutierrez
@dearfrankg
Oct 11 2016 20:43
@spencern you coerced him to sleep
Spencer Norman
@spencern
Oct 11 2016 20:44
:zzz: