My question is do I ever need to use the form tag?
No, you never need to use a form tag. All backbone communication is via ajax.
Yes, as others have mentioned you can optionally construct your form tags, HTML, URLs, and server side code so they work correctly when used via regular form submission and full page loads.
I never use form tags, and here's why:
- I structure my backbone API URIs to match REST conventions, and my page URIs only sometimes correlate to those
- I think immediate autosave is a vastly superior interaction pattern, so when you check any checkbox, I send an AJAX PUT and your change is saved immediately without a submit button or full page load. Note that the default behavior of
Backbone.Model
is to send the entire record, which is not my personal preference, but I'm more of an RPC mindset vs REST.
- I probably don't want to code my server to work in both single-page fashion and multi-page fashion as doing so is vastly more difficult than the basic single-page style and not worth the effort unless you have extenuating circumstances requiring this.
- a single page app just needs a basic index.html, a REST API that returns JSON exclusively, and a boatload of browser JS
- if you want to be able to handle some or all of your operations via full page loads, you have a lot more server side coding to do to render server side HTML that exactly matches what your backbone browser code would do. You need something like airbnb/rendr, and it's non-trivial to put it lightly. Since your example indicates an ASP server, have fun sharing templates between ASP and backbone.
- if you don't include the
form
tags at all, you know you don't have to test them. If you include them, you are implying maybe they work, and then probably you should test them.
- if you don't include the
form
tags at all, it's one less unexpected set of HTTP requests to worry about on your server. It's clearer about your intent. It's an AJAX/JSON API. That's OK, embrace it.
On the whole "users with javascript disabled" thing - please stop saying this. Can anyone point to a single web application that uses backbone.js when JS is enabled AND can function with JS disabled? I don't think one has ever been written. Plus, it would feel like a time warp to a decade ago. If you are building a backbone app, you are whole-hog into JS. If you want your site to work without JS, don't use backbone, use a traditional multi-page web application framework.