1

We have an existing application using dijit controls. The previous behavior on pre FF6 when the control is focused is it also gets selected. However, starting FF6 the control is no longer selecting all text. The problem now is there are a lot of dojo.byId('ctrlId').focus() in our code. I can fix that by adding a dojo.byId('ctrlId').select() code after each focus call. but I am looking for a more global way to fix this.

I tried overriding the focus method but it does not work.

HTMLFormElement.prototype._select = HTMLFormElement.prototype.select;
dijit.prototype.focus = function() {
    this.focus.apply();
    this.select.apply();
}

Any ideas?

Nap
  • 8,096
  • 13
  • 74
  • 117

1 Answers1

2

Firstly, you should be using dijit.byId not dojo.byId. Dijits are complex classes and using dijit.byId will ensure you are targetting the right thing.

Secondly, which Dijit are you using? You can see a list here: http://dojotoolkit.org/api/1.6/dijit/form

Thirdly, I'm not entirely sure what you mean by "when the control is focused is it also gets selected". Do you mean the text inside the dijit is selected?

Assumig we're dealing with a dijit.form.TextBox, how about catching the focus event and forcing a select? Something like this:

dojo.connect( dijit.byId('ctrlId'), 'focus',  function() { dojo.query( 'input', dijit.byId('ctrlId' ).domNode )[0].select() } );

(I've not tested this but you get the idea I hope.)

voidstate
  • 7,937
  • 4
  • 40
  • 52
  • Hi voidstate, yes I am using diji.form.TextBox. And yes, select means select all text currently in the textbox. I could do the focus event but that would mean I need to write a connect statement for all instance of the control. I am wondering if it is possible by just one single code for all instance of text boxes. so if i call the focus() method, it just selects all text inside the text box. – Nap Oct 31 '11 at 01:15