Telerik Rad Editor error: Uncaught TypeError: Cannot read property ‘selection’ of undefined

  javascript, radeditor, telerik

I’m using Telerik’s Rad Editor User Control in a .NET WebForms application and under a certain scenario where the control is loaded dynamically by another control (a custom made control to create slots for controls in a Bootstrap container), I get a JavaScript console error:

Uncaught TypeError: Cannot read property 'selection' of undefined
    at b.Selection.getRange (ScriptResource.axd?d=SIX1nT3k5ctYiH_Z5iBDXeNFwtqET1GhsSanY7Q2h153yCssqUubU-GpHlcfK8gjX18hWLTSlaoUT61q-SQGy93hbZvclqscj-nR3zsEFjsKVmi494CYjyylWVkR3eNNKVpNg7B80Wty2P3dJY6cUA2&t=fffffffff49535ad:7690)
    at c.RadEditor.getDomRange (ScriptResource.axd?d=SIX1nT3k5ctYiH_Z5iBDXeNFwtqET1GhsSanY7Q2h153yCssqUubU-GpHlcfK8gjX18hWLTSlaoUT61q-SQGy93hbZvclqscj-nR3zsEFjsKVmi494CYjyylWVkR3eNNKVpNg7B80Wty2P3dJY6cUA2&t=fffffffff49535ad:8708)
    at c.RadEditor.getSelectedElement (ScriptResource.axd?d=SIX1nT3k5ctYiH_Z5iBDXeNFwtqET1GhsSanY7Q2h153yCssqUubU-GpHlcfK8gjX18hWLTSlaoUT61q-SQGy93hbZvclqscj-nR3zsEFjsKVmi494CYjyylWVkR3eNNKVpNg7B80Wty2P3dJY6cUA2&t=fffffffff49535ad:8696)
    at Telerik.Web.UI.Editor.Modules.RadEditorNodeInspector._updateMainPanel (ScriptResource.axd?d=lDDHa0Hv-PJAN7f-FaZrY8GR5a2KHyxptYnV1LPwAtwaMypvJNIv502xGvb3veyLQ81luqxDIOQkVZla3DTGc2U7WxvxtxteKVuAFLgkMtEuQHVZF5AunA48-SvSdYuVngV4ZxTltdcg1EQck5MUNA2&t=fffffffff49535ad:760)
    at Array.<anonymous> (ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQmaA3NBOrEhteJFHcIRwB3LbyNJLc58uLZS3p2EDH9seCQ3yfEfq4RTzDmER0JwBm5pEEGC4K5jzj7yrdvsS84XELmTf74MZGfrxdgZ1HPIDrSBKGK-wyFiO2YT6gwXs0LkNxMdjE2R_blGbZYvQERM1&t=4065f642:47)
    at ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQmaA3NBOrEhteJFHcIRwB3LbyNJLc58uLZS3p2EDH9seCQ3yfEfq4RTzDmER0JwBm5pEEGC4K5jzj7yrdvsS84XELmTf74MZGfrxdgZ1HPIDrSBKGK-wyFiO2YT6gwXs0LkNxMdjE2R_blGbZYvQERM1&t=4065f642:3484
    at c.RadEditor.raiseEvent (ScriptResource.axd?d=TDVjdgRbdvNAY3tnbizUcL3JaN9wGBAwgfOiAoQz-8_sx4RBS_CNJR_6oyOAcd8DHTq1s2xNxOyyUnkgggf-tAyta9xM2l9z8rqN2ujl-PpwBmtdC9cWe3dSvrKEBU8E0&t=fffffffff49535ad:1070)
    at Function.Type$callBaseMethod [as callBaseMethod] (ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQmaA3NBOrEhteJFHcIRwB3LbyNJLc58uLZS3p2EDH9seCQ3yfEfq4RTzDmER0JwBm5pEEGC4K5jzj7yrdvsS84XELmTf74MZGfrxdgZ1HPIDrSBKGK-wyFiO2YT6gwXs0LkNxMdjE2R_blGbZYvQERM1&t=4065f642:625)
    at c.RadEditor.raiseEvent (ScriptResource.axd?d=SIX1nT3k5ctYiH_Z5iBDXeNFwtqET1GhsSanY7Q2h153yCssqUubU-GpHlcfK8gjX18hWLTSlaoUT61q-SQGy93hbZvclqscj-nR3zsEFjsKVmi494CYjyylWVkR3eNNKVpNg7B80Wty2P3dJY6cUA2&t=fffffffff49535ad:8211)

I’m guessing it has to do with how the control is rendered and Rad Editor not being able to find the element on the page. I’m reading Teleriks documentation on this but it appears that where the error is being thrown is in their JavaScript. What do I need to check/look for that would tell me in the WebForms side of things that the Rad Editor will have issues finding the control?

Source: Ask Javascript Questions

LEAVE A COMMENT