From a0079f570ce996cb5acbf050a7abb1df1ad788eb Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 18 Jun 2012 18:56:04 -0700 Subject: Hintable - Fix editable/hintable value property so it is bindable. --- js/components/editable.reel/editable.js | 45 +++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'js/components/editable.reel/editable.js') diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index 103e418f..88b93b2c 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js @@ -93,12 +93,43 @@ exports.Editable = Montage.create(Component, { } } }, + + _value : { value: null }, value : { - get: function() { - return this._element.textContent; - }, - set: function(str) { - this._element.textContent = str; + get : function() { return this._value; }, + set : function(value) { + if(value === this._value) { return; } + + var node = this._getFirstTextNode(); + node.textContent = value; + + this._value = value; + } + }, + _getFirstTextNode : { + value : function(el) { + ///// optional el argument specified container element + var e = el || this._element, + nodes = e.childNodes, node; + + if(nodes.length) { + for(var i=0; i