$(document).ready and RadControl's availability

Thread is closed for posting
7 posts, 0 answers
  1. Sub
    Sub avatar
    91 posts
    Member since:
    Nov 2007

    Posted 29 Apr 2009 Link to this post

    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

     

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 29 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff Nafe
    Jeff Nafe avatar
    46 posts
    Member since:
    Sep 2007

    Posted 23 Mar 2010 Link to this post

    I am having a similar issue in which the pageLoad event is being fired twice. Was the cause of this firing twice ever determined?
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 24 Mar 2010 Link to this post

    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.
  6. Jeff Nafe
    Jeff Nafe avatar
    46 posts
    Member since:
    Sep 2007

    Posted 24 Mar 2010 Link to this post

    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!
  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 24 Mar 2010 Link to this post

    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.
  8. Kevin
    Kevin avatar
    4 posts
    Member since:
    Sep 2008

    Posted 20 May 2010 Link to this post

    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


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017