javascript - Meteor template helper not working after using iron router -


i'm new meteor , installed iron router project. have inside application.js file:

if (meteor.isclient) {    template.nav.helpers({     ismobile: function(){       if(ismobile.tablet) {         return false;       } else if(ismobile.phone) {         return true;       } else {         return false;       }     }   });  } 

the ismobile helper used inside nav template this:

<template name="nav"> ...   {{#if ismobile}}     {{> mobile_nav}}   {{else}}     {{> desktop_nav}}   {{/if}}           ... </template> 

what i'm doing here is, i'm loading 2 different sets of navigation. if user using desktop or tablet, i'm going show desktop_nav template , when user using phone, i'm going show mobile_nav.

this jquery plugin use inside ismobile template helper.

inside application.html file, have this:

<head>     <meta charset="utf-8" />     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />     <title>example</title> </head>  <body> </body>  <template name="main">     {{> nav}}            {{> yield}}     {{> footer}} </template> 

and router.js file:

router.configure({     layouttemplate: 'main' });  router.route('/', 'home');  router.route('/about', 'about'); 

my problem right is, ismobile template helper doesn't work. nav template loaded if else block not working.

it working fine before start using iron router.

what missing here?

note, project structure tree:

├── application.css.scss ├── application.html ├── application.js ├── client │   ├── javascripts │   │   ├── ismobile.min.js │   │   └── router.js │   ├── stylesheets │   │   └── ... │   └── views │       ├── about.html │       ├── home.html │       ├── home.js │       └── layouts │           ├── desktop_nav.html │           ├── footer.html │           ├── mobile_nav.html │           └── nav.html └── public     ├── fonts     │   └── ...     └── images         └── ... 

you should render templates layout. here tutorial can you.

http://iron-meteor.github.io/iron-router/#rendering-templates-into-regions-with-javascript

so this:

router.route('/', function () {   this.render('main'); }); 

also check console in browser, might have errors iron router


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -