Permalink
Browse files

Reattaching the click handler and being more explicit about getting t…

…he containing form.
  • Loading branch information...
1 parent a690514 commit cf0b035815ab1aa8acf35536a487b44d9838693b @jnewman committed Mar 30, 2012
Showing with 18 additions and 5 deletions.
  1. +13 −2 ui/Button.js
  2. +5 −3 ui/ClearButton.js
View
@@ -2,10 +2,21 @@ define([
'module', '../util/class/declare', 'dijit/form/Button'
], function (module, declare, Button) {
return declare(module.id, [Button], {
+ /**
+ * Wipe out the existing template.
+ *
+ * @type {string}
+ */
templateString: '',
+
+ /**
+ * Re-add all the attach-points and attach the click handler.
+ */
buildRendering: function () {
- this.domNode = this.focusNode = this.iconNode = this.srcNodeRef;
- this.srcNodeRef = '';
+ this.domNode = this.valueNode = this.titleNode = this.focusNode = this.iconNode = this.srcNodeRef;
+ delete this.srcNodeRef;
+
+ this.connect(this.domNode, 'click', this._onClick);
}
});
});
View
@@ -19,15 +19,15 @@ define([
this.containingForm = getAncestors(this.domNode).filter(function (ancestor) {
return ancestor.nodeName === 'FORM';
- });
+ }).pop();
},
/**
* Clear all the inputs in the containingForm.
*/
onClick: function () {
- var form = this.containingForm;
- form.set && form.set('value', (function () {
+ var form = dijit.byNode(this.containingForm);
+ form && form.set && form.set('value', (function () {
var values = {};
var key = '';
@@ -37,6 +37,8 @@ define([
return values;
})());
+
+ return false;
}
});
})

0 comments on commit cf0b035

Please sign in to comment.