This is a migrated thread and some comments may be shown as answers.

radprompt, radalert, radconfirm not available at windows.load

4 Answers 137 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jan Hansen
Top achievements
Rank 1
Jan Hansen asked on 13 Feb 2009, 04:07 PM
Hi,

I currently need to display a radprompt dialog "when the page loads". I cant just output some javascript during page_load, as this will be executed before the radwindowmanager is ready, which is also the case for observing dom:loaded or window.load.

As stated in this thread

http://www.telerik.com/community/forums/aspnet-ajax/window/using-radalert-as-server-side-messagebox.aspx

we are adviced to register the script we need to run "when the page loads" in a

Sys.Application.add_load( ... code ...);


which apparently works fine - but in AJAX callback environments this thread
http://vaultofthoughts.net/SysApplicationaddloadFiresOnEachCallback.aspx
and partly this one as well
http://www.tvidesign.co.uk/blog/sys.application.add_load-in-Firefox-3.aspx
suggests that the method will be called multiple times:

"It comes out that add_load fires on each callback and not only when the page loads for the first time. That is of course a problem if you want something to happen on page load only."

which is not what we want. We want to execute it at "load".

The problem is of  course that we cant rely on testing when the dom or page is ready, as the telerik components are created with the MS AJAX framework and so we have to wait for the components to be ready. Could you introduce a "OnClientLoadCompleted" method on the RadWindowManager (and probably on the other compoents as well) - perhaps even a more "global" event mechanism that would let us know when the individual Telerik components or all of them are completed loading and are ready for interaction?

/Jan

4 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 16 Feb 2009, 07:29 AM
Hi Jan Hansen,

Yes, you are right - Sys.Application.Load is called on every Ajax call. To ensure that your code is called once only, you can use the following logic
var f = function() 
    //your code here 
    Sys.Application.remove_load(f); 
Sys.Application.add_load(f); 

As you can see, the idea is to remove the function from the Load event once it is executed.


Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jan Hansen
Top achievements
Rank 1
answered on 17 Feb 2009, 08:12 AM
OK, tnanks. That will work - but it stil seems as a bit of a hack. Could you please add a clientside "loadcompleted" event to the wishlist - that way we don't have to add/remove event listeners to the MS ajax framework, but can keep interaction with the components themselves ?

/Jan
0
Accepted
Georgi Tunev
Telerik team
answered on 17 Feb 2009, 01:17 PM
Hello Jan,

I apologize for not providing more information in my previous reply. There is no need to add such functionality to our controls for such scenario as the ASP.NET AJAX framework already have one - the pageLoad() function.
If you put such function in your ASP.NET AJAX-enabled page, the code in it will be called when all ASP.NET AJAX controls (including ours) are loaded on the page.
for example:
function pageLoad() 
    var oWnd = $find("<%= RadWindow1.ClientID %>"); 
    oWnd.show() 



All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jan Hansen
Top achievements
Rank 1
answered on 17 Feb 2009, 01:27 PM
OK, didn't know that :o) Thanks for the help.
Tags
Window
Asked by
Jan Hansen
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Jan Hansen
Top achievements
Rank 1
Share this question
or