开发者

Rails 3 - Using link_to but adding a # for AJAX Deep Linking

Currently my links in Rails are using link_to as follows:

<%= link_to project.name, pro开发者_开发知识库ject %>

Which makes something like: <a href="/projects/1">Project 1</a>

I'm working to implement an AJAX app with deep linking so instead of the above, I want the output to be (with a #): <a href="#/projects/1">Project 1</a>

Is there a way to get this to work with link_to? Or do I need some type of custom helper so I can use something like link_deep_to

Thanks


I recommend instead of <a href="#/projects/1">Project 1</a> to have

<a href="/projects/1" class="deep_linker">Project 1</a>

And then use jQuery to attach to all links with class of deep_linker. That way your javascript is unobtrusive.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜