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 +1 -1
- data/lib/generators/backbone/scaffold/templates/router.coffee +5 -5
- data/lib/generators/backbone/scaffold/templates/views/edit_view.coffee +11 -11
- data/lib/generators/backbone/scaffold/templates/views/index_view.coffee +5 -5
- data/lib/generators/backbone/scaffold/templates/views/model_view.coffee +2 -2
- data/lib/generators/backbone/scaffold/templates/views/new_view.coffee +11 -11
- data/lib/generators/backbone/scaffold/templates/views/show_view.coffee +1 -1
- data/vendor/assets/javascripts/backbone.js +3 -3
- metadata +4 -7
data/README.md
CHANGED
@@ -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
|
-
@
|
14
|
-
success:(
|
15
|
-
@
|
16
|
-
window.location.hash = "/#{@
|
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(@
|
19
|
+
render : ->
|
20
|
+
$(this.el).html(this.template(@model.toJSON() ))
|
21
21
|
|
22
|
-
this.$("form").backboneLink(@
|
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',
|
9
|
+
@options.<%= plural_model_name %>.bind('reset', @addAll)
|
10
10
|
|
11
11
|
addAll: () ->
|
12
|
-
@options.<%= plural_model_name %>.each(
|
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
|
-
|
16
|
+
@$("tbody").append(view.render().el)
|
17
17
|
|
18
18
|
render: ->
|
19
|
-
$(
|
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
|
-
@
|
12
|
+
@model.destroy()
|
13
13
|
this.remove()
|
14
14
|
|
15
15
|
return false
|
16
16
|
|
17
17
|
render: ->
|
18
|
-
$(this.el).html(
|
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
|
-
@
|
11
|
+
@model = new @collection.model()
|
12
12
|
|
13
|
-
@
|
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
|
-
@
|
21
|
+
@model.unset("errors")
|
22
22
|
|
23
|
-
@
|
24
|
-
success: (
|
25
|
-
@
|
26
|
-
window.location.hash = "/#{@
|
23
|
+
@collection.create(@model.toJSON(),
|
24
|
+
success: (<%= singular_name %>) =>
|
25
|
+
@model = <%= singular_name %>
|
26
|
+
window.location.hash = "/#{@model.id}"
|
27
27
|
|
28
|
-
error: (
|
29
|
-
@
|
28
|
+
error: (<%= singular_name %>, jqXHR) =>
|
29
|
+
@model.set({errors: $.parseJSON(jqXHR.responseText)})
|
30
30
|
)
|
31
31
|
|
32
32
|
render: ->
|
33
|
-
$(this.el).html(
|
33
|
+
$(this.el).html(@template(@model.toJSON() ))
|
34
34
|
|
35
|
-
this.$("form").backboneLink(@
|
35
|
+
this.$("form").backboneLink(@model)
|
36
36
|
|
37
37
|
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
|
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`
|
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.
|
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-
|
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
|
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:
|
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
|
|