문제

I need to implement an MVC JavaScript framework for my next project, but it's as much as a website as it is a web app. Is it possible to expose the data server-side, then parse the URL to show the 'JS version'?

(I plan on using Rails for server-side code)

도움이 되었습니까?

해결책

I wrote a small blog series on exactly this subject...

The first part introduces the problem and the previous solutions, as well as the current solution: HTML5's PushState (history API)

http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-1-introducing-pushstate/

Part 2 shows how to use progressive enhancement with Backbone, so that when you have your server render HTML you can then have your Backbone code take over the existing HTML content instead of rendering new content:

http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-2-progressive-enhancement-with-backbone-js/

Part 3 is a (slightly blurry) video of a presentation I gave on this subject, at a conference:

http://lostechies.com/derickbailey/2011/10/06/seo-and-accessibility-with-html5-pushstate-part-3-the-video/

And while it's not directly a part of this little series, I also wrote a blog post about using Routers with PushState. The gist of that post is: you don't need a router:

http://lostechies.com/derickbailey/2011/10/17/tips-for-using-backbone-js-routers-with-html5-pushstate/

Hope that helps

다른 팁

Im not really sure if I understand your question the right way. I think you have some data and you want to work with it on the server side using rails and then provide it to your javascript and proceed working with the data? Thats right?

Then yes thats possible. Lets say you have a model called article and you access one article by the following url:

http://site.com/articles/1

then you can add an .xml

http://site.com/articles/1.xml

and you will get xml and of cause Javascript can parse xml. This is the default setting of rails.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top