简体   繁体   中英

MeteorJS external files: css and js

I am trying to add this bootstrap theme to my project http://ironsummitmedia.github.io/startbootstrap-creative/ this theme have 4 js files beside jquery and bootstrap.

I added jquery and bootstrap to my project, This 4 files are in the compatibility folder, as Metereor doc said, but It did not work. The navbar effect when scroll down the page is not working and I sometimes(If I leave the .js files name untouched) got an error about fitText.js file.

PD1: Compatibility folder loads the .js files in alphabetical order.

PD2: I tried a lot of suggestions that I found, here in stack and meteor forums but nothing happen.

I put css and less files in client/lib/stylesheet and they seens to be ok.

What can I do to make this theme to work in meteor.?

Thanks.

NOTE: JS Files

  • 1.jquery.easing.min.js
  • 2.jquery.fittext.js
  • 3.wow.min.js

  • 4.creative.js

I place them with creative theme load order

You have two primary options:

  1. Create a meteor package . If you do a nice job of this then you might wish to share it with the community via atmosphere.js and github so that everyone else can take advantage of your work.
  2. Put your theme's .js files under /public then create a file somewhere in your /client directory tree called head.html that doesn't include any <template name="foo"> directives. Instead just include the directives you want in the <head> section of all your pages bracketed by <head> and </head> . Refer to your .js files from that section of html.

The <head> section is also useful for establishing your google SEO codes and also your google webmaster tools verification code.

I found a solution that works perfect. I hope it could help other people, I use jquery and .rendered to load the scrips after the page is fully rendered and all the effects I wanted to use where available

Template.layout.rendered = function() {

  $('head').append('<script type="text/javascript" src="/javascript/jquery.easing.min.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/jquery.fittext.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/wow.min.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/creative.js"></script>');

}

There is no need to provide the reference of stylesheets in the meteor. Just put your CSS file in client/stylesheets folder. Meteor will automatically apply these CSS rules.

And the same goes with JS as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM