Meteor: Add Bootstrap CDN links before admin dashboard route -
enter code here
i using materializecss
ui of app. want add admin package , using yogiben:admin package. problem use admin package have install bootstrap
packae can't because using materializecss
ui work.
now there little hack trying do, add bootstrap cdn links before /admin
route.
can me how add links bootstrap cdn on fly. when user logged in admin , go /admin
route or /admin/*
bootstrap css , javascript should loaded.
i trying this:
router.route("admin", { path: admindashboard.path('/admin'), onbeforeaction: function(){ link: { stylesheet: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" } this.next(); } });
but above code gives error
error: route path "/admin" exists name of "admin".
never mind. managed myself. here solution if else looking 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>")); } });
Comments
Post a Comment