views:

57

answers:

1

Hello,

Currently my links in Rails are using link_to as follows:

<%= link_to project.name, project %>

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

+1  A: 

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.

Jesse Wolgamott
Hmm that's interesting... Whats wrong with doing this in Rails? Also, won't that be a huge performance hit on the client's browser?
AnApprentice
No, you won't notice the hit for jQuery to select "a.deep_linker" and then attaching to its click event. There's nothing "wrong" with doing what you've said, but it guarantees that it won't work in a non-ajax environment.
Jesse Wolgamott
Shoot. so I'm using jQuery BBQ for deep linking and this won't play nicely with that plugin.... so any solutions for making a link_deep_to in rails? So type of helper? I agree that it's not good for non-ajax env, but I know very few of those. And my app isn't to be crawled by google. I also don't want to overbuild so early?
AnApprentice