Skip to content

Commit

Permalink
Merge pull request #1332 from bryan-m-hughes/timob-7512
Browse files Browse the repository at this point in the history
[TIMOB-7512] Added support for proper change event firing in text contro...
  • Loading branch information
cb1kenobi committed Feb 2, 2012
2 parents 9edb804 + a1b00cb commit 0135d67
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions mobileweb/src/Ti/_/UI/TextBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define("Ti/_/UI/TextBox",
["Ti/_/declare", "Ti/_/dom", "Ti/_/event", "Ti/_/style", "Ti/_/UI/FontWidget", "Ti/UI"],
function(declare, dom, event, style, FontWidget, UI) {
["Ti/_/declare", "Ti/_/dom", "Ti/_/event", "Ti/_/style", "Ti/_/lang", "Ti/_/UI/FontWidget", "Ti/UI"],
function(declare, dom, event, style, lang, FontWidget, UI) {

return declare("Ti._.UI.TextBox", FontWidget, {

Expand Down Expand Up @@ -31,8 +31,26 @@ define("Ti/_/UI/TextBox",
require.on(field, "keypress", this, function() {
this._capitalize();
});
require.on(field, "change", this, function() {
this.fireEvent("change");

var updateInterval = null,
previousText = "";
require.on(field, "focus", this, function(){
updateInterval = setInterval(lang.hitch(this,function(){
var value = field.value,
newData = false;
if (previousText.length != value.length) {
newData = true;
} else if(previousText != value) {
newData = true;
}
if (newData) {
this.fireEvent("change");
previousText = value;
}
}),200);
});
require.on(field, "blur", this, function(){
clearInterval(updateInterval);
});
},

Expand Down

0 comments on commit 0135d67

Please sign in to comment.