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

Calling $find find method from JS file.

1 Answer 104 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Pruthvi
Top achievements
Rank 1
Pruthvi asked on 07 Oct 2020, 12:33 PM

Hi, We need help here. I want to call this 

var editor = $find("<%=editor1.ClientID %>");

var someContent = editor.get_html();

from .JS file instead of .aspx file. But when I am calling $find method from function which reside in .JS file, getting "$find is not defined" error.

Please advice how to fix this.

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 09 Oct 2020, 06:25 PM

Hi Pruthvi,

Server-side scripts (<%= %>) are evaluated only inside aspx pages while the external JavaScript files are static. To achieve what you are looking for you might declare a global js variable and assign its value in the Editor's OnClientLoad event handler:

*.aspx file
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="onEditorLoad"></telerik:RadEditor>

*.js file
            var editor;

            function onEditorLoad(sender, args) {
                editor = sender;
            }
            function theFunctionWhereYouNeedTheEditor() {
                var someContent = editor.get_html();
            }

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Editor
Asked by
Pruthvi
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or