backbone_extensions 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,30 @@
1
1
  (function(_, Backbone) {
2
2
  'use strict';
3
3
  function bindModelEvents(tuple) {
4
- var self = this, subject = tuple[0], isJquery = !!_(subject).result('jquery'), eventNames = tuple[1], modelEvents = self._modelEvents;
4
+ var self = this, subject = tuple[0], eventNames = tuple[1], isJquery = !!_(subject).result('jquery'),
5
+ modelEvents = self._modelCallbacks, context = tuple[2];
5
6
  modelEvents.push(tuple);
6
7
 
7
8
  _(subject && eventNames).each(function(callback, event) {
8
9
  _(event.split(' ')).each(function(e) {
9
10
  _([callback]).chain().flatten().each(function(c) {
10
- if (_(c).isFunction()) {
11
+ var fn = _(c).isFunction() ? c : self[c];
11
12
  if (isJquery) {
12
- subject.on(e, c);
13
+ if (context) {
14
+ subject.on(e, context, fn);
15
+ } else {
16
+ subject.on(e, fn);
17
+ }
13
18
  } else {
14
- subject.on(e, c, self);
19
+ subject.on(e, fn, context);
15
20
  }
16
- } else {
17
- if (!isJquery) {
18
- subject.on(e, self[c], self);
19
- }
20
- }
21
21
  });
22
22
  });
23
23
  });
24
24
  }
25
25
 
26
26
  function unbindModelEvents() {
27
- var self = this, modelEvents = self._modelEvents;
27
+ var self = this, modelEvents = self._modelCallbacks;
28
28
  _(modelEvents).each(function(tuple) {
29
29
  var subject = tuple[0], events = tuple[1];
30
30
 
@@ -54,7 +54,7 @@
54
54
  included: function(source) {
55
55
  _(source.prototype).extend({
56
56
  initialize: _(source.prototype.initialize).wrap(function(oldInitialize, attrsOrModels, options) {
57
- this._modelEvents = [];
57
+ this._modelCallbacks = [];
58
58
  oldInitialize.call(this, attrsOrModels, options);
59
59
  }),
60
60
 
@@ -1,3 +1,3 @@
1
1
  module BackboneExtensions
2
- VERSION = '0.0.21'
2
+ VERSION = '0.0.22'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backbone_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: -3936213747677424289
129
+ hash: 3574570062899009095
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  none: false
132
132
  requirements:
@@ -135,10 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: -3936213747677424289
138
+ hash: 3574570062899009095
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 1.8.24
141
+ rubygems_version: 1.8.21
142
142
  signing_key:
143
143
  specification_version: 3
144
144
  summary: Extensions to backbone javascript library as a rails engine