tentjs-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,3 +15,49 @@ And then execute:
15
15
  Or install it yourself as:
16
16
 
17
17
  $ gem install tentjs-rails
18
+
19
+ ## Using Tent
20
+
21
+ Rather than extending Backbone prototypes directly, Tent builds on top of them. That way, you can still create vanilla Backbone View, Models, and Collections without the additions that Tent provides. So, creating a view that uses Tent's extensions looks like this:
22
+
23
+ ```
24
+ view = new Tent.View();
25
+ ```
26
+
27
+ ## Tent.View
28
+
29
+ ### Binding to an object
30
+
31
+ By binding to an object using the `view.bindTo()` function, one can ensure that the binding is released when the view is closed using Tent's `view.close()` function.
32
+
33
+ ```
34
+ view.bindTo(view.model, 'change', view.doSomething);
35
+ ```
36
+
37
+ `bindTo` limits you to using the calling object as the context, which makes unbinding easier. If you must use another object as the context for a binding callback, use Backbone's `on` function.
38
+
39
+
40
+ ### Unbinding from an object
41
+
42
+ Unbinding from an object is done with `unbindFrom`:
43
+
44
+ ```
45
+ view.unbindFrom(view.model);
46
+ ```
47
+
48
+ ### Releasing all bindings
49
+
50
+ When closing a view, Tent's `close` function takes care of releasing bindings made with `bindTo`, but the bindings can also all be released with `unbindAll`.
51
+
52
+ ```
53
+ view.unbindAll();
54
+ ```
55
+
56
+ ### Closing a view
57
+
58
+ Calling `view.close()` will do a fiew things:
59
+
60
+ 1. Call `view.beforeClose()` if it's been defined.
61
+ 2. Call `view.unbindAll()` to get rid of bindings.
62
+ 3. Call `view.off()` to get rid of DOM bindings.
63
+ 4. Call `view.remove()` to remove the view DOM element itself.
@@ -5,7 +5,7 @@
5
5
 
6
6
  object.on(event, callback, this);
7
7
 
8
- if (!_.contains(this._bindings)) {
8
+ if (!_.contains(this._bindings, object)) {
9
9
  this._bindings.push(object);
10
10
  }
11
11
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tentjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: