This is a migrated thread and some comments may be shown as answers.
$(document).ready and RadControl's availability
6 Answers 254 Views
This is a migrated thread and some comments may be shown as answers.
Sub
Top achievements
Rank 1
Sub asked on 29 Apr 2009, 03:35 PM
I am populating the RadComboBox in the $(document).ready method in MVC project. It shows RadComboBox object does not exist error when I access it like "$find("<%= combobox.ClientId%>"); If I use PageLoad function instead of (document).ready then it works but PageLoad is called twice.

I appreciate any sugesstion to solve this issue!

thanks

 

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Apr 2009, 03:45 PM
Hi Sub,

Being an ASP.NET Ajax control RadComboBox is initialized later than the document.ready event. You should use the pageLoad event. It is however very strange that it fires two times. I am sending you a sample project in which pageLoad fires only one time. What is different in your case?

Regards,
Albert
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
Jeff Nafe
Top achievements
Rank 1
answered on 23 Mar 2010, 01:46 PM
I am having a similar issue in which the pageLoad event is being fired twice. Was the cause of this firing twice ever determined?
0
Veselin Vasilev
Telerik team
answered on 24 Mar 2010, 01:20 PM
Hi Jeff Nafe,

I am afraid no.
Do you reproduce the problem in a simple application (without Telerik controls)?
Does it happen once you drop a RadControl on the page?

All the best,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jeff Nafe
Top achievements
Rank 1
answered on 24 Mar 2010, 01:23 PM
Thanks Veskoni-

After my post, I realized the issue. Our specific page was loading initially, then based on the user's preferences, it selects a drop down list value which causes a postback. Due to this, the client side pageLoad event fires again. I have changed it to basically add some "If Not Postback" type functionality based on a variable that we set. So, I should be good, but thanks for the answer. If there is some client side variable equivalent to ASP.NETs Page.IsPostBack, that would be helpful, but I'm not aware of one.

Thanks!
0
T. Tsonev
Telerik team
answered on 24 Mar 2010, 01:31 PM
Hello Jeff,

I'll also note that the pageLoad function will be executed after every AJAX update. If you only need to execute code on initial page load you should use the following approach:

Sys.Application.add_load(function loadHandler() {
    alert(1);
     
    Sys.Application.remove_load(loadHandler);
});

I hope this helps.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin
Top achievements
Rank 1
answered on 20 May 2010, 10:04 PM
While developing a custom control, I came across this same problem and found this thread and thought I would offer a solution that expanded on the last relpy. I was using a MultiPage control as the backing for a property. During initialize (on the client-side) I was setting the index of the view, but the object wasn't available yet. I ended up writing a very short jQuery plugin that streamlined my library and thought I'd share.

//plugin  
jQuery.pageLoad = function(handler) 
    Sys.Application.add_load(function loadHandler() 
    { 
        handler(); 
        Sys.Application.remove_load(loadHandler); 
    }); 
}; 
 
//usage with anonymous function or named
$.pageLoad(function() 
   //execution here 
}); 

I could now add handlers to the "pageLoad" and have the single execution where all objects would be available.

Regards,
Kevin Hillinger


Asked by
Sub
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jeff Nafe
Top achievements
Rank 1
Veselin Vasilev
Telerik team
T. Tsonev
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or