dba47367 by Michael Richards

Build 0.5.8.

1 parent ee557a0c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 "name": "rivets", 2 "name": "rivets",
3 "repo": "mikeric/rivets", 3 "repo": "mikeric/rivets",
4 "description": "Declarative data binding facility.", 4 "description": "Declarative data binding facility.",
5 "version": "0.5.7", 5 "version": "0.5.8",
6 "keywords": ["data binding", "templating"], 6 "keywords": ["data binding", "templating"],
7 "scripts": ["dist/rivets.js"], 7 "scripts": ["dist/rivets.js"],
8 "main": "dist/rivets.js", 8 "main": "dist/rivets.js",
......
1 // Rivets.js 1 // Rivets.js
2 // version: 0.5.7 2 // version: 0.5.8
3 // author: Michael Richards 3 // author: Michael Richards
4 // license: MIT 4 // license: MIT
5 (function() { 5 (function() {
...@@ -173,10 +173,31 @@ ...@@ -173,10 +173,31 @@
173 } 173 }
174 }; 174 };
175 175
176 Binding.prototype.update = function() { 176 Binding.prototype.update = function(models) {
177 this.unbind(); 177 var _ref;
178 this.model = this.key ? this.view.models[this.key] : this.view.models; 178
179 return this.bind(); 179 if (models == null) {
180 models = {};
181 }
182 if (this.key) {
183 if (models[this.key]) {
184 if (!this.options.bypass) {
185 this.view.config.adapter.unsubscribe(this.model, this.keypath, this.sync);
186 }
187 this.model = models[this.key];
188 if (this.options.bypass) {
189 this.sync();
190 } else {
191 this.view.config.adapter.subscribe(this.model, this.keypath, this.sync);
192 if (this.view.config.preloadData) {
193 this.sync();
194 }
195 }
196 }
197 } else {
198 this.sync();
199 }
200 return (_ref = this.binder.update) != null ? _ref.call(this, models) : void 0;
180 }; 201 };
181 202
182 return Binding; 203 return Binding;
...@@ -404,28 +425,20 @@ ...@@ -404,28 +425,20 @@
404 }; 425 };
405 426
406 View.prototype.update = function(models) { 427 View.prototype.update = function(models) {
407 var binding, key, model, _results; 428 var binding, key, model, _i, _len, _ref, _results;
408 429
409 if (models == null) { 430 if (models == null) {
410 models = {}; 431 models = {};
411 } 432 }
412 _results = [];
413 for (key in models) { 433 for (key in models) {
414 model = models[key]; 434 model = models[key];
415 this.models[key] = model; 435 this.models[key] = model;
416 _results.push((function() { 436 }
417 var _i, _len, _ref, _results1; 437 _ref = this.bindings;
418 438 _results = [];
419 _ref = this.select(function(b) {
420 return b.key === key;
421 });
422 _results1 = [];
423 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 439 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
424 binding = _ref[_i]; 440 binding = _ref[_i];
425 _results1.push(binding.update()); 441 _results.push(binding.update(models));
426 }
427 return _results1;
428 }).call(this));
429 } 442 }
430 return _results; 443 return _results;
431 }; 444 };
...@@ -631,6 +644,9 @@ ...@@ -631,6 +644,9 @@
631 return delete this.nested; 644 return delete this.nested;
632 } 645 }
633 } 646 }
647 },
648 update: function(models) {
649 return this.nested.update(models);
634 } 650 }
635 }, 651 },
636 unless: { 652 unless: {
...@@ -643,6 +659,9 @@ ...@@ -643,6 +659,9 @@
643 }, 659 },
644 routine: function(el, value) { 660 routine: function(el, value) {
645 return Rivets.binders["if"].routine.call(this, el, !value); 661 return Rivets.binders["if"].routine.call(this, el, !value);
662 },
663 update: function(models) {
664 return Rivets.binders["if"].update.call(this, models);
646 } 665 }
647 }, 666 },
648 "on-*": { 667 "on-*": {
...@@ -737,6 +756,24 @@ ...@@ -737,6 +756,24 @@
737 } 756 }
738 } 757 }
739 return _results; 758 return _results;
759 },
760 update: function(models) {
761 var data, key, model, view, _i, _len, _ref, _results;
762
763 data = {};
764 for (key in models) {
765 model = models[key];
766 if (key !== this.args[0]) {
767 data[key] = model;
768 }
769 }
770 _ref = this.iterated;
771 _results = [];
772 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
773 view = _ref[_i];
774 _results.push(view.update(data));
775 }
776 return _results;
740 } 777 }
741 }, 778 },
742 "class-*": function(el, value) { 779 "class-*": function(el, value) {
......
1 { 1 {
2 "name": "rivets", 2 "name": "rivets",
3 "description": "Declarative data binding facility.", 3 "description": "Declarative data binding facility.",
4 "version": "0.5.7", 4 "version": "0.5.8",
5 "author": "Michael Richards", 5 "author": "Michael Richards",
6 "url": "http://rivetsjs.com", 6 "url": "http://rivetsjs.com",
7 "main": "./dist/rivets.js", 7 "main": "./dist/rivets.js",
......
1 # Rivets.js 1 # Rivets.js
2 # ========= 2 # =========
3 3
4 # > version: 0.5.7 4 # > version: 0.5.8
5 # > author: Michael Richards 5 # > author: Michael Richards
6 # > license: MIT 6 # > license: MIT
7 # > 7 # >
......