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
Post a Comment