TIMEX
TIMEX

Reputation: 272094

How do you deal with forms when using Backbone.js?

<form action="???" method="POST">
    <input type="text" name="content">
</form>

Suppose I'm using Backbone.js's "routes" feature, and I build dynamic web apps.

Let's say I want to implement a normal form. When the user submits something, how would that work?

I understand how Backbone.js works with anchor links (using the routes #) , but I can't wrap my head around best practices with forms and backbone.js

Upvotes: 1

Views: 356

Answers (1)

mhansen
mhansen

Reputation: 1141

If your site is using the hash fragment, you probably want to do submit your forms using AJAX, rather than a full page reload using a POST.

I would use jQuery.post, with a custom success and error handler that you can control from your JavaScript, to redirect to a hash.

Upvotes: 2

Related Questions