rails-backbone 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Backbone-Rails
1
+ # Backbone-Rails [![Build Status](https://secure.travis-ci.org/codebrew/backbone-rails.png)](https://secure.travis-ci.org/codebrew/backbone-rails)
2
2
 
3
3
  Easily setup and use backbone.js (0.5.0) with rails 3.1
4
4
 
@@ -4,11 +4,11 @@ class <%= router_namespace %>Router extends Backbone.Router
4
4
  @<%= plural_model_name %>.reset options.<%= plural_model_name %>
5
5
 
6
6
  routes:
7
- "/new": "new<%= class_name %>"
8
- "/index": "index"
9
- "/:id/edit": "edit"
10
- "/:id": "show"
11
- ".*": "index"
7
+ "/new" : "new<%= class_name %>"
8
+ "/index" : "index"
9
+ "/:id/edit" : "edit"
10
+ "/:id" : "show"
11
+ ".*" : "index"
12
12
 
13
13
  new<%= class_name %>: ->
14
14
  @view = new <%= "#{view_namespace}.NewView(collection: @#{plural_name})" %>
@@ -1,24 +1,24 @@
1
1
  <%= view_namespace %> ||= {}
2
2
 
3
3
  class <%= view_namespace %>.EditView extends Backbone.View
4
- template: JST["<%= jst 'edit' %>"]
4
+ template : JST["<%= jst 'edit' %>"]
5
5
 
6
- events:
7
- "submit #edit-<%= singular_name %>": "update"
6
+ events :
7
+ "submit #edit-<%= singular_name %>" : "update"
8
8
 
9
- update: (e) ->
9
+ update : (e) ->
10
10
  e.preventDefault()
11
11
  e.stopPropagation()
12
12
 
13
- @options.model.save(null,
14
- success:(model) =>
15
- @options.model = model
16
- window.location.hash = "/#{@options.model.id}"
13
+ @model.save(null,
14
+ success : (<%= singular_name %>) =>
15
+ @model = <%= singular_name %>
16
+ window.location.hash = "/#{@model.id}"
17
17
  )
18
18
 
19
- render: ->
20
- $(this.el).html(this.template(@options.model.toJSON() ))
19
+ render : ->
20
+ $(this.el).html(this.template(@model.toJSON() ))
21
21
 
22
- this.$("form").backboneLink(@options.model)
22
+ this.$("form").backboneLink(@model)
23
23
 
24
24
  return this
@@ -4,19 +4,19 @@ class <%= view_namespace %>.IndexView extends Backbone.View
4
4
  template: JST["<%= jst 'index' %>"]
5
5
 
6
6
  initialize: () ->
7
- _.bindAll(this, 'addOne', 'addAll', 'render');
7
+ _.bindAll(this, 'addOne', 'addAll', 'render')
8
8
 
9
- @options.<%= plural_model_name %>.bind('reset', this.addAll);
9
+ @options.<%= plural_model_name %>.bind('reset', @addAll)
10
10
 
11
11
  addAll: () ->
12
- @options.<%= plural_model_name %>.each(this.addOne)
12
+ @options.<%= plural_model_name %>.each(@addOne)
13
13
 
14
14
  addOne: (<%= singular_model_name %>) ->
15
15
  view = new <%= view_namespace %>.<%= singular_name.camelize %>View({model : <%= singular_model_name %>})
16
- this.$("tbody").append(view.render().el)
16
+ @$("tbody").append(view.render().el)
17
17
 
18
18
  render: ->
19
- $(this.el).html(this.template(<%= plural_model_name %>: this.options.<%= plural_model_name %>.toJSON() ))
19
+ $(@el).html(@template(<%= plural_model_name %>: @options.<%= plural_model_name %>.toJSON() ))
20
20
  @addAll()
21
21
 
22
22
  return this
@@ -9,11 +9,11 @@ class <%= view_namespace %>.<%= singular_name.camelize %>View extends Backbone.V
9
9
  tagName: "tr"
10
10
 
11
11
  destroy: () ->
12
- @options.model.destroy()
12
+ @model.destroy()
13
13
  this.remove()
14
14
 
15
15
  return false
16
16
 
17
17
  render: ->
18
- $(this.el).html(this.template(this.options.model.toJSON() ))
18
+ $(this.el).html(@template(@model.toJSON() ))
19
19
  return this
@@ -8,9 +8,9 @@ class <%= view_namespace %>.NewView extends Backbone.View
8
8
 
9
9
  constructor: (options) ->
10
10
  super(options)
11
- @options.model = new @options.collection.model()
11
+ @model = new @collection.model()
12
12
 
13
- @options.model.bind("change:errors", () =>
13
+ @model.bind("change:errors", () =>
14
14
  this.render()
15
15
  )
16
16
 
@@ -18,20 +18,20 @@ class <%= view_namespace %>.NewView extends Backbone.View
18
18
  e.preventDefault()
19
19
  e.stopPropagation()
20
20
 
21
- @options.model.unset("errors")
21
+ @model.unset("errors")
22
22
 
23
- @options.collection.create(@options.model.toJSON(),
24
- success: (model) =>
25
- @options.model = model
26
- window.location.hash = "/#{@options.model.id}"
23
+ @collection.create(@model.toJSON(),
24
+ success: (<%= singular_name %>) =>
25
+ @model = <%= singular_name %>
26
+ window.location.hash = "/#{@model.id}"
27
27
 
28
- error: (model, jqXHR) =>
29
- @options.model.set({errors: $.parseJSON(jqXHR.responseText)})
28
+ error: (<%= singular_name %>, jqXHR) =>
29
+ @model.set({errors: $.parseJSON(jqXHR.responseText)})
30
30
  )
31
31
 
32
32
  render: ->
33
- $(this.el).html(this.template(@options.model.toJSON() ))
33
+ $(this.el).html(@template(@model.toJSON() ))
34
34
 
35
- this.$("form").backboneLink(@options.model)
35
+ this.$("form").backboneLink(@model)
36
36
 
37
37
  return this
@@ -4,5 +4,5 @@ class <%= view_namespace %>.ShowView extends Backbone.View
4
4
  template: JST["<%= jst 'show' %>"]
5
5
 
6
6
  render: ->
7
- $(this.el).html(this.template(this.options.model.toJSON() ))
7
+ $(this.el).html(@template(@model.toJSON() ))
8
8
  return this
@@ -31,8 +31,8 @@
31
31
  var _ = root._;
32
32
  if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;
33
33
 
34
- // For Backbone's purposes, jQuery or Zepto owns the `$` variable.
35
- var $ = root.jQuery || root.Zepto;
34
+ // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
35
+ var $ = root.jQuery || root.Zepto || root.ender;
36
36
 
37
37
  // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
38
38
  // to its previous owner. Returns a reference to this Backbone object.
@@ -984,7 +984,7 @@
984
984
  // Ensure that the View has a DOM element to render into.
985
985
  // If `this.el` is a string, pass it through `$()`, take the first
986
986
  // matching element, and re-assign it to `el`. Otherwise, create
987
- // an element from the `id`, `className` and `tagName` proeprties.
987
+ // an element from the `id`, `className` and `tagName` properties.
988
988
  _ensureElement : function() {
989
989
  if (!this.el) {
990
990
  var attrs = this.attributes || {};
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rails-backbone
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.3
5
+ version: 0.5.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Fitzgerald
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-08-13 00:00:00 -04:00
14
+ date: 2011-09-04 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: 3.1.0.rc5
24
+ version: 3.1.0
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: *id001
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- hash: 2831200879708897934
106
+ hash: -3422163520620027386
107
107
  segments:
108
108
  - 0
109
109
  version: "0"
@@ -112,9 +112,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- hash: 2831200879708897934
116
- segments:
117
- - 0
118
115
  version: "0"
119
116
  requirements: []
120
117