Skip to content

Instantly share code, notes, and snippets.

@Kalyse
Created April 13, 2011 12:03
Show Gist options
  • Save Kalyse/917419 to your computer and use it in GitHub Desktop.
Save Kalyse/917419 to your computer and use it in GitHub Desktop.
Allow a dijit to be focusable in a Textbox. (Yes I know that dijit.grid.cells._Widget and _Base exists exactly for this purpose, but I wanted to do it without doing that).
formatCurrency: function(value, idx){
if(!this._widgets[idx]){
this._widgets[idx] = new dijit.form.TextBox(
{ value: value,
constraints: {pattern:"#,###,###.00"}
});
this._widgets[idx]._connection = dojo.connect(this._widgets[idx], "onFocus", function(e,f,g){
setTimeout(dojo.hitch(this,function(){
dojo.disconnect(this._connection);
dojox.grid.util.fire(this,"focus");
}),90);
} );
this._widgets[idx]._connection = dojo.connect(this._widgets[idx], "onBlur", function(e,f,g){
this._widgets[idx]._connection = dojo.connect(this._widgets[idx], "onFocus", function(e,f,g){
setTimeout(dojo.hitch(this,function(){
dojo.disconnect(this._connection);
dojox.grid.util.fire(this,"focus");
}),90);
} );
} );
}
return this._widgets[idx];
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment