Browse files

don't assume .all has items, call

  • Loading branch information...
1 parent ce7abad commit fbfa81608d78f86ed95129319186c4d26489c5c9 Kamil Tusznio committed Sep 16, 2011
Showing with 13 additions and 10 deletions.
  1. +1 −1 index.coffee
  2. +10 −7 index.js
  3. +2 −2 js/batman.js
View
2 index.coffee
@@ -8,7 +8,7 @@ class Tracer.AppController extends Batman.Controller
index: -> @render false
submitSearch: =>
Tracer.set 'hasSearched', yes
- Tracer.Tweet.all.forEach (t) -> t.destroy()
+ Tracer.Tweet.all?.forEach (t) -> t.destroy()
$.ajax 'http://search.twitter.com/search.json?q=' + encodeURI(Tracer.query),
dataType: 'jsonp'
success: (data) ->
View
17 index.js
@@ -36,18 +36,21 @@
return this.render(false);
};
AppController.prototype.submitSearch = function() {
+ var _ref;
Tracer.set('hasSearched', true);
- Tracer.Tweet.all.forEach(function(t) {
- return t.destroy();
- });
+ if ((_ref = Tracer.Tweet.all) != null) {
+ _ref.forEach(function(t) {
+ return t.destroy();
+ });
+ }
$.ajax('http://search.twitter.com/search.json?q=' + encodeURI(Tracer.query), {
dataType: 'jsonp',
success: function(data) {
- var obj, tweet, _i, _len, _ref, _results;
- _ref = data.results;
+ var obj, tweet, _i, _len, _ref2, _results;
+ _ref2 = data.results;
_results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- obj = _ref[_i];
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ obj = _ref2[_i];
tweet = new Tracer.Tweet(obj);
_results.push(tweet.save(function(error, record) {
if (error) {
View
4 js/batman.js
@@ -639,7 +639,7 @@
if (isGlobal === false) {
return;
}
- return container[this.name] = this;
+ return container[$functionName(this)] = this;
};
BatmanObject.classMixin = function() {
return $mixin.apply(null, [this].concat(__slice.call(arguments)));
@@ -2197,7 +2197,7 @@
options = {};
}
if (!this.prototype._batman.getAll('storage').length) {
- throw new Error("Can't load model " + this.name + " without any storage adapters!");
+ throw new Error("Can't load model " + ($functionName(this)) + " without any storage adapters!");
}
this.loading();
return this.prototype._doStorageOperation('readAll', options, __bind(function(err, records) {

0 comments on commit fbfa816

Please sign in to comment.