how to Close radWindow by clicking outside of it

2 posts, 0 answers
  1. Maruthi
    Maruthi avatar
    4 posts
    Member since:
    Jul 2012

    Posted 20 Jul 2012 Link to this post

    On click of ContactUs i am calling OpenVideoContactForm(this) 

    <script type="text/javascript">
    function OpenVideoContactForm() 
    {
    var oWnd = radopen('/_layouts/ContactUsPopupBranding/ContactUs.aspx','miniRadWindow');
    oWnd.setSize(500,550);
    } 
    </.script>


    <td class="globalLogin" onclick="OpenVideoContactForm();">Contact us</td>

    The form is opening fine 
    but
    on mouse click outside the form i should close the form.

    Can anyone tell me how to achieve this?



  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Jul 2012 Link to this post

    Hello,

    Try the following javascript to close the RadWindow on clicking outside.
    aspx:
    <td class="globalLogin" onclick="OpenVideoContactForm(this); return false;">Contact us</td>
    JS:
    <script type="text/javascript">
    function pageLoad()
    {
      $addHandler(document, "click", onClickHandler);
    }
     var lastOpenedWindow;
     var clickedtd;
     function OpenVideoContactForm(td)
     {
       clickedtd = td;
       var oWindow = radopen('/_layouts/ContactUsPopupBranding/ContactUs.aspx','miniRadWindow');
       lastOpenedWindow = oWindow;
     }
     function onClickHandler(e)
     {
      var targedNodeName = e.target;
      if (lastOpenedWindow && (targedNodeName != clickedtd))
     {
       // If the RadWindow is clicked then do nothing ;
        if ($telerik.isMouseOverElementEx(lastOpenedWindow.get_popupElement(), e)) return;
        lastOpenedWindow.close();
        lastOpenedWindow = null;
        clickedtd = null;
      }
    }
    </script>

    Thanks,
    Princy.
Back to Top