jquery - Javascript gets current Controller and Action on Rails -


is there way javascript knows current controller , action in rails?

i have idea create hidden container current controller , controller. know if javascript has function know current controller , action.

javascript runs client side , has absolutely no idea controller or action is, there cannot function use obtain sort of information.

but can teach javascript concept. alter layout sth (haml assumed):

%body{data: {controller: params[:controller], action: params[:action]}} 

you can obtain data using jquery:

controllername = $('body').data('controller') actionname = $('body').data('action') 

now quesstion is, why want this. client side client side , mixing client side logic server side implementation might dangerous.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -