开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜