Damian Mehers' Blog Android, VR and Wearables from Geneva, Switzerland.

21Feb/072

Initializing PopupBehavior in your AJAX Control Extender initialize method won’t work

In the ListSearchExtender which I am currently working to contribute to the AJAX Control Toolkit I use the PopupBehavior to display a DIV next to the ListBox (rendered as a SELECT) which initially has a message such as "Type to search...".  This is then replaced as the user types characters, with the characters they have typed.

If the user sets the ListBox to have the default focus (via the form's defaultFocus property) then I want to show the Prompt DIV immediately, which I initially tried doing in my control extender's initialize method.  This didn't work, and the reason is that there is a second initialization pass that takes place for the PopupBehavior, that is called by the framework, which hides the element (my DIV) associated with the PopupBehavior.  This second pass takes place after my extender's initialize method is called.

The workaround I used was to register a method to be called after all controls are initialized.  That would be the Sys.Application.load method:

this._applicationLoadDelegate = Function.createDelegate(this, this._onApplicationLoad);
Sys.Application.add_load(
this._applicationLoadDelegate);


My delegate gets called after all scripts have been loaded and the objects in the application have been created and initialized.

Filed under: AJAX Leave a comment
Comments (2) Trackbacks (0)
  1. For completeness, I should mentiion that I call Sys.Application.remove_load in the extender’s “dispose” method (I’m calling Sys.Application.add_load in the initialize).


Leave a comment

No trackbacks yet.