Javascript include control depending on page -


i'm working client-side developer on web app , found myself having lots of modules, each 1 different pages. wonder idea include depending on route myself (in javascript) or pass responsibility back-end (ruby on rails) guys.

i suppose need application.js included in every page, , in this:

if (window.location.href == '.../somepage') {     loadscript('somepagecontrols.js') }  if (window.location.href == '.../anotherpage') {     ... } 

any thoughts?

ok, not simple answer @ all, since there , there theese ruby-guys, hope ok beetwen you! ;)

although if don't want bother theese guys, ( know not easy work in team ) can ask include 1 ruby file working folder ex.

/web-app/ruby-guys/you/ruby-js.rb 

now can work unique file , load here js file need. using eaxmple switch-case

case url-query   when x     # print out drag-drop.js   when y, z     # print out mouse-move.js  

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -