Permalink
Browse files

Catching and printing error after calling binders' init/bind method, …

…this prevents binders from interfering with each other and also ensures that the mojito-client finishes processing everything.
  • Loading branch information...
1 parent 42cc294 commit 5a9f3120c08d132b504af7cc96b9e287d86830cc @aljimenez aljimenez committed Jun 19, 2014
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/app/autoload/mojito-client.client.js
@@ -137,7 +137,11 @@ YUI.add('mojito-client', function(Y, NAME) {
if (Y.Lang.isFunction(binder.bind)) {
// Pass the "node" to the bind method
- binder.bind(node, element);
+ try {
+ binder.bind(node, element);
+ } catch (e) {
+ Y.log(e.stack || e.message, 'error');
+ }
}
// all automatic event delegation
if (Y.Lang.isFunction(binder.handleClick)) {
@@ -641,11 +645,14 @@ YUI.add('mojito-client', function(Y, NAME) {
});
if (Y.Lang.isFunction(binder.init)) {
- binder.init(mojitProxy);
+ try {
+ binder.init(mojitProxy);
+ } catch (e) {
+ Y.log(e.stack || e.message, 'error');
+ }
}
onBinderComplete();
-
});
}, this);
@@ -1018,7 +1025,11 @@ YUI.add('mojito-client', function(Y, NAME) {
if (Y.Lang.isFunction(childBinder.onRefreshView)) {
childBinder.onRefreshView(childNode, childElement);
} else if (Y.Lang.isFunction(childBinder.bind)) {
- childBinder.bind(childNode, childElement);
+ try {
+ childBinder.bind(childNode, childElement);
+ } catch (e) {
+ Y.log(e.stack || e.message, 'error');
+ }
}
});

0 comments on commit 5a9f312

Please sign in to comment.