Rad Editor Scrolls the page when loaded.

6 posts, 0 answers
  1. Edward
    Edward avatar
    12 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2012 Link to this post

    On our site we have javascript that uses the ScrollIntoView(), but when the RadEditor loads, after ScrollIntoView has been called and the screen is in the correct place, it scrolls the user back up to the RadWindow.
    Is there any way to disable the RadEditor from scrolling the screen back up?
    Or is there a way I can call our scroll code again once the RadEditor has loaded?
    Thanks,
    Edward
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Sep 2012 Link to this post

    Hi Edward,

    You can call your function in OnClientLoad event of RadEditor as follows.

    JS:
    function OnClientLoad()
    {
     setTimeout(function ()
     {
      // Your Code  
     }, 100);
    }

    Hope this helps.

    Thanks,
    Princy.
  3. Edward
    Edward avatar
    12 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    I tried setting the OnClientLoad property of the RadEditor tag to the name of our method.
    The method executes, but the jQuery selector we use to find the element we want to scroll to no longer finds anything.
    I also tried using setTimeout on the first call, but with no luck.
    Will combining the two change the result somehow?

    Is your code equivalent?
    Why would a selector not work when run on a callback from OnClientLoad?
  4. Edward
    Edward avatar
    12 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    This is the snippet we execute to scroll to the element:
                var messageDiv = $("[name=" + "m_" + messageId + "]").parent();
                messageDiv[0].scrollIntoView(true);

    Here is the error message:
    1. Uncaught TypeError: Cannot call method 'scrollIntoView' of undefined Default.aspx:4280
      1. jumpToMessageWithIdDefault.aspx:4280
      2. jumpToMessageFromQueryStringDefault.aspx:4272
      3. scrollToMessageFixDefault.aspx:4268
      4. Telerik.Web.UI.RadWebControl.raiseEventTelerik.Web.UI.WebResource.axd:765
      5. Sys.Component.endUpdateTelerik.Web.UI.WebResource.axd:6
      6. Sys._Application.endCreateComponentsTelerik.Web.UI.WebResource.axd:6
      7. Sys._Application._doInitializeTelerik.Web.UI.WebResource.axd:6
  5. Edward
    Edward avatar
    12 posts
    Member since:
    Sep 2012

    Posted 23 Sep 2012 Link to this post

    @Princy: Your answer doesn't work for scrolling the page, it just returns the same error.
  6. Rumen
    Admin
    Rumen avatar
    14324 posts

    Posted 24 Sep 2012 Link to this post

    Hello,

    For some reason this line var messageDiv = $("[name=" + "m_" + messageId + "]").parent(); returns null. You should make sure that messageDiv returns a correct reference to the object to which you want to scroll the page.

    Kind regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top