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

Can't reopen Radwindow after close it

3 Answers 253 Views
Window
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 17 Mar 2015, 08:53 PM
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!

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 18 Mar 2015, 08:05 AM

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.

 
0
Chris
Top achievements
Rank 1
answered on 18 Mar 2015, 02:56 PM
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,

0
Marin Bratanov
Telerik team
answered on 19 Mar 2015, 07:23 AM

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.

 
Tags
Window
Asked by
Chris
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Chris
Top achievements
Rank 1
Share this question
or