Ok guys, I originally set out to render the users' NewView onto my root page. I have gotten to the point where I can see the form, but when I fill it out and click "Create User" I get this error:
TypeError: this.model is undefined
$(this.el).html(this.template(this.model.toJSON()));
Here is the relevant code:
index.html.erb
<div id="container">Loading...</div>
<script type="text/javascript">
$(function() {
window.newView = new Example.Views.Users.NewView({model: <%= @users.to_json.html_safe -%>,collection: new Example.Collections.UsersCollection()});
window.router = new Example.Routers.UsersRouter({users: <%= @users.to_json.html_safe -%>});
$('body').html(newView.render().$el);
Backbone.history.start();
});
</script>
Here is one question I posted today which has brought me to this question...reading the comments should be helpful!
ReferenceError: users is not defined rails + backbone + firebug
I have a feeling it has something to do with the fact that I created two windows? "window.newView" and "window.router".
There needs to be a router for Backbone.history.start() to work...correct? This is why I added the router line in the first place...because I was getting an error with Backbone.history.start().