2

I'm looking into using Backbone.js and node.js to write a small web app. Sharing code between the client and sever is attractive.

I can't figure out how clients without JS (and search engines) should interact with the site. How should form validations and rendering work with no client-side JavaScript work?

Of course, I'd like to do this without code duplication. Seems to me the point of Backbone.js and other server-side js is that you can have the same form validations and template/view generation on the server AND client.

1
  • form validation is done on the server. rendering is done on the server (data -> html translation). Commented Sep 5, 2011 at 20:37

2 Answers 2

3

If you have your view coded with javascript, search engines are buggered as they conform to a more traditional web (one url, one state, one page) and don't understand javascript.

You need to use graceful up-gradation if you want to provide a rich experience and support search engines.

With graceful up-gradation, you code your website with no client side javascript, get it all working nice a nifty. Then you use javascript to upgrade the experience. In most cases this is actually easier, as the upgrade process can be automated. See https://github.com/browserstate/ajaxify

Sign up to request clarification or add additional context in comments.

3 Comments

Right -- but I was hoping that sharing code between server and client (and having the server generate the view/html code with the same javascript as would run on the client) would make it possible to make sites that would work with no client-side javascript without having to duplicate code.
I'm not sure how to have backbone.js render views on the server side for clients without javascript enabled. I'm not sure how to have backbone.js on the server handle form validation. None of the tutorials/examles I've seen show backbone.js (or other frameworks) working without client-side js enabled.
You can create server-side windows with the jsdom package. See gist.github.com/1191942 and tumblr.balupton.com/post/9761563646/fn-or for an example which uses jQuery
0

Validating the form data on the client side is a good practice because it saves a user from potentially having to re-enter what was written if it does not validate on the server. Validating on the client side does not remove the need to validate on the server, as your question helps point out, because there is no guarantee JavaScript will be running or even that the form used is the one on your server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.