Skip to content

Commit

Permalink
Fix for issue AmpersandJS#137
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanspears committed Jul 22, 2015
1 parent 1bbceac commit 6f0e7c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ampersand-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ assign(View.prototype, {
}
};
function action() {
var el, subview;
var el, subview, waitFor;
// if not rendered or we can't find our element, stop here.
if (!this.el || !(el = this.query(opts.selector))) return;
if (!opts.waitFor || getPath(this, opts.waitFor)) {
waitFor = getPath(this, opts.waitFor);
if (!opts.waitFor || waitFor || (waitFor !== undefined && waitFor !== null)) {

This comment has been minimized.

Copy link
@pgilad

pgilad Aug 26, 2015

Can you extract this entire check as a function? i.e:

function isSubviewReady(view, waitFor) {
  if (!waitFor) return true;
  var value = getPath(view, waitFor);
  return value !== undefined && value !== null;
}

And then call it if (isSubviewReady(this, opts.waitFor))

subview = this[name] = opts.prepareView.call(this, el);
subview.render();
this.registerSubview(subview);
Expand Down

0 comments on commit 6f0e7c8

Please sign in to comment.