More in this section

Forums / Developing with Sitefinity / Interesting onClick problem in RadEditor within Generic Content editing

Interesting onClick problem in RadEditor within Generic Content editing

2 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    11 Mar 2009
    Link to this post
    So, I've extended the Hyperlink editing capabilities so users can make their links open in pop-over windows (using RadWindow).  It is working very well.

    I am having one problem in IE however.   The HTML that my custom hyperlinks generate look something like this:

    <p><a href="/MattTest/RegistrationTest2.aspx" onclick="openRadWindow(this.href, 'Popover Modal',500,700,true); return false;" target="_blank" sfref="~/MattTest/RegistrationTest2.aspx">Popover Modal</a></p


    I have a function I wrote called openRadWindow() which does a bunch of sizing and all before calling the standard RadWindow client side open functions.  Now, the problem is when a user is editing the content in the RadEditor, if they just click on the text of one of the links (in the Design view), they get a Javascript error because it is actually trying to execute the onclick event.  

    I had hoped that the AllowScripts tag would help me here, but that just prevents <script> tags from being entered into the HTML view.

    I thought I would just put a dummy javascript function on the GenericContentDesigner.ascx page and have it return false - but that actually doesn't work.   I could of course, have it call top.openRadWindow() and it would call the function in the top main frame - but I don't want it to actually open the window; and I have no way of knowing that the call came from someone who is editing.

    The more I thought about this, the more I was suprised that in design view, any javascript events at all are handled?  I would think it should ignore all of those things.  Imagine editing something that had a bunch of links that had onfocus and onblur events - you wouldn't want those events to take place when in design view (but perhaps you would in preview view).
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    17 Mar 2009
    Link to this post
    Hello,

    It seems, the problem is caused by the fact that a function (object) with the name openRadWindow cannot be found. So, a possible solution is to check if the javascript function is defined on the page.

    <p><a href="/Sitefinity3.5SP1/MattTest/RegistrationTest2.aspx" onclick="if(typeof(openRadWindow) != 'undefined'){openRadWindow(this.href, 'Popover Modal',500,700,true); return false;}" target="_blank" sfref="~/MattTest/RegistrationTest2.aspx">Popover Modal</a></p

    Do let us know if this helps.

    Sincerely yours,
    Pepi
    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.
2 posts, 0 answered