sudojs-rails 0.5.4 → 0.5.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee9300e874fa0fdcd967acbc29597e642ffd823b
4
- data.tar.gz: 200973d4c5bb4f220e06a1d566f060310924b795
3
+ metadata.gz: 8ce00bbcc867422371ddb22d8105e34d97ac4b5f
4
+ data.tar.gz: 223bafb13bd62591e3d048c3e0b7de721115f6e9
5
5
  SHA512:
6
- metadata.gz: 9ba5c7d810fbde242a538aa14f6a8972aed7f9ec8462632a8790f87e7432e6171512d24dfb4bdd26e06d0fc6a63e6b584c70ccc7aca51fd56005c091c672b766
7
- data.tar.gz: 5bd6329229084695d1706991b6a5fc9996f20705cc24210e8b6392e10660bbd6ba867f0c996cc9092af5d7f0018f49147bdbf18a0b5ba491d0932a82da9d1c80
6
+ metadata.gz: 162bf0d1c377bb2b5b1dbcec422d12536f2ad6d43e7bcd3a9f65b703446c030afa50992dcb168dd3e485f3643f51ec39ae9e93895836fc8d1d6f2181245dd3e3
7
+ data.tar.gz: bc2fcbdc78e33b4d0805af2a601535db81032b043fa97a1ac139946a2879d5b768f9b16e0908f3f2b8de33c568b6814ae972ca1c4bf8a0c5598d538797cf8d59
@@ -1,3 +1,3 @@
1
1
  module Sudojs
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -770,16 +770,14 @@ sudo.DataView = function(el, data) {
770
770
  sudo.View.call(this, el, data);
771
771
  // implements the listener extension
772
772
  $.extend(this, sudo.extensions.listener);
773
- // dataview's models are observable, make it so if not already
774
- if(!this.model.observe) $.extend(this.model, sudo.extensions.observable);
775
- // dont autoRender on the setting of events,
776
- // add to this to prevent others if needed
777
- this.autoRenderBlacklist = {event: true, events: true};
778
- // if autorendering, observe your own model
779
- // use this ref to unobserve if desired
780
- if(this.model.data.autoRender) this.observer = this.model.observe(this.render.bind(this));
781
- // only call the initial build if not an autoRender type
782
- else this.build();
773
+ if(this.model.data.autoRender) {
774
+ // dont autoRender on the setting of events,
775
+ this.autoRenderBlacklist = {event: true, events: true};
776
+ // autoRender types observe their own model
777
+ if(!this.model.observe) $.extend(this.model, sudo.extensions.observable);
778
+ // you may need to override `build` if you provide a template and the data
779
+ // isnt hydrated (as that is the expectation)
780
+ } else this.build();
783
781
  if(this.role === 'dataview') this.init();
784
782
  };
785
783
  // `private`
@@ -790,8 +788,10 @@ sudo.inherit(sudo.View, sudo.DataView);
790
788
  // if not an autoRender (which will render on model change), as well as setup the events (in children too)
791
789
  sudo.DataView.prototype.addedToParent = function(parent) {
792
790
  this.bindEvents();
793
- // autoRender Dataviews should only render on model change
791
+ // non-autoRender types should render now
794
792
  if(!this.model.data.autoRender) return this.render();
793
+ // autoRender Dataviews should only render on model change
794
+ else this.observer = this.model.observe(this.render.bind(this));
795
795
  return this;
796
796
  };
797
797
  // ###build
@@ -819,6 +819,8 @@ sudo.DataView.prototype.build = function build() {
819
819
  sudo.DataView.prototype.removeFromParent = function removeFromParent(keep) {
820
820
  this.parent.removeChild(this);
821
821
  this.unbindEvents().$el[keep ? 'detach' : 'remove']();
822
+ // in the case that this.model is 'foreign'
823
+ if(this.observer) this.model.unobserve(this.observer);
822
824
  return this;
823
825
  };
824
826
  // ###render
@@ -833,15 +835,14 @@ sudo.DataView.prototype.removeFromParent = function removeFromParent(keep) {
833
835
  //
834
836
  // `returns` {Object} `this`
835
837
  sudo.DataView.prototype.render = function render(change) {
836
- var d;
837
838
  // return early if a `blacklisted` key is set to my model
838
839
  if(change && this.autoRenderBlacklist[change.name]) return this;
839
- d = this.model.data;
840
840
  // has `build` been executed already? If not call it again
841
841
  if(!this.built) this.build();
842
842
  // if there is no template by this point *you are doing it wrong*
843
843
  // erase the flag
844
844
  else this.built = false;
845
+ d = this.model.data;
845
846
  if(d.renderTarget) {
846
847
  this._normalizedEl_(d.renderTarget)[d.renderMethod || 'append'](this.$el);
847
848
  delete d.renderTarget;
@@ -1468,6 +1469,7 @@ sudo.extensions.persistable = {
1468
1469
  //
1469
1470
  // `param` {string} `base` the baseUrl set in this models ajax options
1470
1471
  url: function url(base) {
1472
+ if(!base) return void 0;
1471
1473
  // could possibly be 0...
1472
1474
  if('id' in this.data) {
1473
1475
  return base + (base.charAt(base.length - 1) === '/' ?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sudojs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - robrobbins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-08 00:00:00.000000000 Z
11
+ date: 2013-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Install the latest versions of sudo.js and provide generators for fast
14
14
  and easy use.