Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Configurable element in routers #114

Open
wants to merge 1 commit into from

1 participant

@zamith

Making the element to which the rendered views are attachment more customizable and caching its jQuery object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2012
  1. @zamith

    Making the element to which the rendered views are attachment more cu…

    zamith authored
    …stomizable and caching its jQuery object
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/generators/backbone/scaffold/templates/router.coffee
View
11 lib/generators/backbone/scaffold/templates/router.coffee
@@ -1,5 +1,6 @@
class <%= router_namespace %>Router extends Backbone.Router
initialize: (options) ->
+ @el = $("#<%= plural_name %>")
@<%= plural_model_name %> = new <%= collection_namespace %>Collection()
@<%= plural_model_name %>.reset options.<%= plural_model_name %>
@@ -8,24 +9,24 @@ class <%= router_namespace %>Router extends Backbone.Router
"index" : "index"
":id/edit" : "edit"
":id" : "show"
- ".*" : "index"
+ ".*" : "index"
new<%= class_name %>: ->
@view = new <%= "#{view_namespace}.NewView(collection: @#{plural_name})" %>
- $("#<%= plural_name %>").html(@view.render().el)
+ @el.html(@view.render().el)
index: ->
@view = new <%= "#{view_namespace}.IndexView(#{plural_name}: @#{plural_name})" %>
- $("#<%= plural_name %>").html(@view.render().el)
+ @el.html(@view.render().el)
show: (id) ->
<%= singular_name %> = @<%= plural_name %>.get(id)
@view = new <%= "#{view_namespace}.ShowView(model: #{singular_name})" %>
- $("#<%= plural_name %>").html(@view.render().el)
+ @el.html(@view.render().el)
edit: (id) ->
<%= singular_name %> = @<%= plural_name %>.get(id)
@view = new <%= "#{view_namespace}.EditView(model: #{singular_name})" %>
- $("#<%= plural_name %>").html(@view.render().el)
+ @el.html(@view.render().el)
Something went wrong with that request. Please try again.