Meteor: Add Bootstrap CDN links before admin dashboard route
Never mind. I managed to do it myself. Here is solution if someone else looking for it.
Router.onAfterAction(function(){
var routeName = Router.current().route.getName();
if ( routeName.indexOf("adminDashboard") == 0 ) {
$("head #injectedBootstrap").remove(); //removes duplicates
$("head").append($("<link rel='stylesheet' id='injectedBootstrap' href='/css/bootstrap.min.css' type='text/css' media='screen' />"));
$("head #injectedBootstrapJs").remove(); //removes duplicates
$("head").append($("<script type='text/javascript' src='/js/bootstrap.min.js'></script>"));
}
});
Customizing Bootstrap while using in Meteor
Use this package to easily customise Bootstrap in Meteor:
https://atmospherejs.com/nemo64/bootstrap
(As was mentioned in the comments already)
Can I mount another route handler through __meteor_bootstrap__.app?
The problem with this solution is that your middleware is put at the bottom of the stack. Therefore the catch-all meteor handler will always run before your "/callback"-handler.
One very hacky way to get around this (until the meteor releases their proper routing support) is to splice in your handler att the top of the stack:
__meteor_bootstrap__.app.stack.splice (0, 0, {
route: '/hello',
handle: function (req,res, next) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("hello world");
return;
}.future ()
});
Rerun Helper Functions on Route Change for Active Links
Yours is a common problem so Mike Fitzgerald has built a package just for this purpose:
https://atmosphere.meteor.com/package/iron-router-active
The given example is like:
<nav>
<ul>
<li class="{{ isActive 'dashboard' }}">...</li>
<li class="{{ isActive 'dashboard|root' }}">...</li>
<li class="{{ isActive 'users' 'on' }}">...</li>
<li class="{{ isActivePath 'products' }}">...</li>
</ul>
</nav>
andd works through handlebars helpers which are called isActive
, isActivePath
, isNotActive
and isNotActivePath
.
Related Topics
How to Restore The "Auto" Values for List-Style-Type in Nested Unordered Lists
Actionview::Template::Error (Variable @Fontawesomeeotpath_Iefix Is Undefined)
How to Change Focus Glow of Textarea in Bootstrap 3
Ie Question: How Many CSS Includes Can It Handle
How to Customize Font Size in Ionic Framework
CSS Style for Links Pointing to The Current Page
How to Render a Border to a Div Without Occupying Any Extra Space
Adding Background Image to Shiny Navbarpage
Borderradius Style Property Not Rounding The Edges in Reactjs
Styling The First 10 Items in a List
Making Responsive Images with Different Aspect Ratios The Same Height
Add CSS to Head from Template File in Magento