How to send the values in paths in jquery?
I'm using the foll开发者_JAVA技巧owing code..
$(document).ready(function(){
$("#test a").click(function(){
var labelTo = $(this).text();
window.location = '#{root_path(labelTo)}';
});
});
I just want to send the value labelTo in root_path..but its giving following error
undefined local variable or method `labelTo' for #
any solution??
If root_path is a function which returns something then you can use like this
$(document).ready(function(){
$("#test a").click(function(){
var labelTo = $(this).text();
window.location = '#' + root_path(labelTo);
});
});
The obvious thought that comes to mind is
window.location = '#{root_path(' + labelTo + ')}';
but what are those braces for?
精彩评论