Can't reopen Radwindow after close it

4 posts, 0 answers
  1. Chris
    Chris avatar
    8 posts
    Member since:
    Mar 2015

    Posted 17 Mar 2015 Link to this post

    Here is the code:
    I put it in RadCodeBlock at first, every thing works fine. I can open it, close it, and reopen it, close again...
    MyWindow is the ID of RadWindow

    function ShowWindow(url, width, height) {
        alert("test");
        var oWnd = $find($telerik.$("[id$='MyWindow']").attr("id"));
        oWnd.show();
        oWnd.setUrl(url);
        oWnd.setSize(width, height);
        oWnd.center();
      
    }

    but after I move this part to external JavaScript file and reference it from the original RadCodeBlock, I can open and close the radwindow, but after closing it, I cannot open it again anymore, but the alert("test") is still working. Can anyone do me a favor to tell me what's the problem in it? Thanks a lot!

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3597 posts

    Posted 18 Mar 2015 Link to this post

    Hello Chris,

    The only reason I can think of for this is having the DestroyOnClose property set to true: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-common.html (see the  Once a RadWindow is closed, it “loses” all its settings (width, height, modality, etc.) section).

    Thus, you can consider adding an API call to disable the destroyOnClose feature, or, just use radopen() and set theneeded settings with JS after that.

    You may also want to review this article in case you have more than one window manager: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-wrong-window-opened.html.

    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    8 posts
    Member since:
    Mar 2015

    Posted 18 Mar 2015 in reply to Marin Bratanov Link to this post

    Thanks,nice hint. Yes, I had tried that before. But it still doesn't work well. I'm curious about why after I move this js part to the external file, it just can't work. 

    I find another issue. After I call close(), the visibility of element Radwindow turns to hidden. Then if I call oWnd.show() again, it tells me "Cannot read property 'show' of null ". Is there any way I could do to fix it?

    Thanks,

  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3597 posts

    Posted 19 Mar 2015 Link to this post

    Hi Chris,

    Could you try this modification:

    var oWnd = $find($telerik.$("[id$='MyWindow']").attr("id").replace("RadWindowWrapper_", ""));

    Here is what happens:

    1. A RadWindow declared in the markup renders a div element with its ClientID (that ends with the server ID). Thus, $find() for that works the first time
    2. RadWindow shows up, so it generates its popup element via JavaScript. Its id is "RadWindowWarpper_" + ClientID of the control. Thus, the second time you execute the jQuery selector, it gets that element, because it is the first child of the <form> element. Thus, you need to make sure you pass only the ClientID of the control to $find()
    3. You close the RadWindow and its popup element is hidden via a CSS property
    4. The next time you attempt to show it, the RadWindowWrapper_ string is returned, so things fail (the selector uses the first match)

    This should have failed in the same manner inline in the aspx page, it should not make a difference whether the code is not in a JS file.

    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top