RadEditor OnClientLoad not firing

1 Answer 19 Views
Editor
Rodney
Top achievements
Rank 2
Rodney asked on 07 May 2024, 10:53 AM

I am trying to remove the curly red underlines for misspelled words and outlined here: Disable browser spellcheck and curly red underlines in RadEditor content area. But the OnClientLoad event never fires. There are no errors on the console log, the editor is enabled, and it is visible.

I'm a little stuck as to what else I can try.

        <div class="SectionBody">
            <telerik:RadEditor ID="redPlan" runat="server" SkinID="EditorDefault" Height="170" Width="500" OnClientLoad="OnClientLoad" />
            <asp:CustomValidator ID="cvPlan" runat="server" ControlToValidate="redPlan" ClientValidationFunction="EditorRequired" ValidateEmptyText="true"
                Text="Required" ValidationGroup="vgDAP" />
        </div>

<telerik:RadScriptBlock runat="server">
    <script type="text/javascript">
        function OnClientLoad(sender, args) {
            sender.get_contentArea().setAttribute("spellcheck", "false");
        }
    </script>
</telerik:RadScriptBlock>


1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 07 May 2024, 11:46 AM

Hi Rodney,

It sounds like you've correctly followed the steps to disable the browser spellcheck in the RadEditor content area, but the OnClientLoad event is not firing. Here are a couple of things you might want to check or try:

  • Ensure the RadEditor is properly initialized: Sometimes, if the RadEditor is not fully initialized by the time scripts are run, event handlers like OnClientLoad might not be properly attached. Make sure there's nothing interfering with the RadEditor's initialization. If needed also set a small timeout in the OnClientLoad function:

            <telerik:RadEditor ID="redPlan" runat="server" SkinID="EditorDefault" OnClientLoad="OnClientLoad" />
            <telerik:RadScriptBlock runat="server">
                <script type="text/javascript">
                    function OnClientLoad(sender, args) {
                        setTimeout(function () {
                            sender.get_contentArea().setAttribute("spellcheck", "false");
                        }, 100);
                    }
                </script>
            </telerik:RadScriptBlock>

  • Temporary disable AJAX to see if the problem is not AJAX related. Set EnableAjax="false" in the RadAjaxPanel/RadAjaxManager and test again. 

  • Check for JavaScript errors elsewhere: While you mentioned there are no errors in the console related to this, ensure there are no other JavaScript errors happening before this script that could potentially halt JavaScript execution.

  • Test with a simplified setup: Temporarily remove other components and custom JavaScript to see if there might be an interaction issue. Sometimes, other scripts or server-side settings can interfere with client-side events.

  • Use Sys.Application.add_load: As an alternative approach, you could try attaching your function after the page has fully loaded, to ensure all components are initialized. For example:

    <telerik:RadEditor ID="redPlan" runat="server" SkinID="EditorDefault"  />
    <telerik:RadScriptBlock runat="server">
        <script type="text/javascript">
            Sys.Application.add_load(function () {
                var editor = $find("<%= redPlan.ClientID %>");
                if (editor) {
                    editor.get_contentArea().setAttribute("spellcheck", "false");
                }
            });
        </script>
    </telerik:RadScriptBlock>

If after trying these steps the issue persists, it might be helpful to gather more details about your setup or any specific configurations you have. This could include details about your browser, any custom JavaScript or server-side configurations that might be relevant. If the problem still cannot be resolved, consider opening a support ticket providing a simple runnable repro project for a test.

    Best Regards,
    Rumen
    Progress Telerik

    Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
    Rodney
    Top achievements
    Rank 2
    commented on 07 May 2024, 12:05 PM

    Attila,

    Thank you for your reply. As I was going through the steps I recalled years ago a skin had been defined for RadEditors and sure enough that had an OnClientLoad even specified. As a result when using that skin, the OnClientLoad I had in the markup was being ignored and the one in the skin was applied.  Once I added the code to disable the browser spellcheck to that script it worked perfectly. Since I wanted this applied to all RadEditors in the project this worked out wonderfully.

    Thanks for the ideas.

    Rodney

    Rumen
    Telerik team
    commented on 07 May 2024, 12:08 PM

    It is great that you found the reason for the issue and fixed it :) 

    Keep up the great work, Rodney!

    Tags
    Editor
    Asked by
    Rodney
    Top achievements
    Rank 2
    Answers by
    Rumen
    Telerik team
    Share this question
    or