Template js not working in meteor app

I have converted HTML template in blaze template but the template is not display correctly. When i open the home page then its almost working fine but when i have tried to navigate on other pages then js stopped working. Please advise that how i can resolve this issue. Thanks in advance.

Can you maybe post some code from your app?

For example:
How do you do your navigation (flow router? Iron router?)?

Your template code would also help.

I have used FlowRouter, Please check template code:
main.html

{{> applicationLayout}}

main.js
if(Meteor.isClient){
Template.applicationLayout.rendered = function(){

    jQuery('html').addClass('transition-navbar-scroll top-navbar-xlarge bottom-footer');

    this.autorun(function(){
        $('head').append('<script type="text/javascript" src="js/vendor/all.js">');
    })
}

}

applicationLayout.html

{{> menu}}
{{> Template.dynamic template=main}}
{{> footer}}

If i added the js inside client dir then meteor built got stuck.
Thanks.

##Packages
First make sure you use those packages:

  • flow-router
  • blaze-layout

You can add them with meteor add kadira:flow-router kadira:blaze-layout.

Structure

Then I’d recommend that you organize all your client side code in folders like so:

client
    components 
        menu.html
        menu.js
        footer.html
        footer.js
    layouts 
        applicationLayout.html
    pages
        pageOne.html
        pageTwo.html
    routes.js
    index.html

Layout Template

In your client/layouts/applicationLayout.html

<template name="applicationLayout">
    {{> menu}} 
    {{> Template.dynamic template=main}} 
    {{> footer}} 
<template>

Routes

In your client/routes.js

FlowRouter.route('/', {
    action: function() {
        BlazeLayout.render('applicationLayout', {
            main: 'pageOne' 
       }
    } 
});

That’s how things are connected on a basic level with Blaze and FlowRouter. See if you can get that set up first.

1 Like

Thanks for your suggestion, i have followed the suggestion but js issue is still there.
URL of site: https://fck-quiz-krugmeisteren.c9users.io/

When i open the home page then its almost working fine but when i have tried to navigate on other pages then js stopped working.Please advise.