Permalink
Browse files

Added data binding to button values and use .text instead of .html fo…

…r the display of labels
  • Loading branch information...
1 parent 26dca3d commit e982b5a40239cb1d94ef680df8debef0cd583fb7 Kevin Holland committed Sep 25, 2009
Showing with 14 additions and 6 deletions.
  1. +12 −4 lib/TC/components/Button.js
  2. +2 −2 lib/TC/components/Label.js
@@ -8,7 +8,7 @@
// data.params.value - text display value on button
TC.components.Button = function (controller, data) {
this.get_haml = function () {
- var layout, params, css, icon_css, label_css, haml;
+ var layout, params, css, icon_css, label_css, haml, value;
layout = this.layout;
params = this.params;
@@ -29,7 +29,15 @@
top: "0",
'line-height': (layout.height - 1) + "px"
};
-
+
+ value = params.value;
+ if (value.bound_variable) {
+ value = params.value.get();
+ controller.listen(params.value.bound_variable, function (value) {
+ $("div div", self.element).text(value);
+ }, self);
+ }
+
haml = [".ui-state-default ui-corner-all", {
css: css,
$: {
@@ -47,10 +55,10 @@
if (params.icon) {
haml.push([".ui-icon.ui-icon-" + params.icon, {css: icon_css}]);
}
- haml.push(["%div", {css: label_css}, params.value]);
+ haml.push(["%div", {css: label_css}, value]);
return haml;
};
TC.Component.apply(this, arguments);
};
-}(jQuery));
+}(jQuery));
@@ -18,7 +18,7 @@
if (value.bound_variable) {
value = params.value.get();
controller.listen(params.value.bound_variable, function (value) {
- $(self.element).html(value);
+ $(self.element).text(value);
}, self);
}
@@ -27,4 +27,4 @@
TC.Component.apply(this, arguments);
};
-}(jQuery));
+}(jQuery));

0 comments on commit e982b5a

Please sign in to comment.