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

$(document).ready not firing when opening new page?

2 Answers 872 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Jay asked on 15 Apr 2015, 09:31 PM

I'm using the NavigateUrl to open a new page. That new page contains some javascript like

$(document).ready(function () {
    alert("ready!");
});
The alert dialog never displays when the window is opened.

Should I not expect the ready function to fire? Is there an alternative? I'm (re)using this window to open many different pages, but only one is trying to use the ready function.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 16 Apr 2015, 11:06 AM

Hi Jay,

RadWindow loads its content page only when it is first shown. Thus, if the page has a proper reference to jQuery, the alert should fire. Could you try loading the same content page in a simple iframe through its src attribute to see if the alert fires as expected? If not, then the issue would be somewhere between the iframe and jQuery and not lie with RadWindow.

Also, can you confirm there are no script errors in the browser console, as this can prevent scripts from running?

Another thing I can suggest is setting the ReloadOnShow property of the RadWindow to true, so each time it opens it will append a random querystring to the page URL so you will always have a GET request for the content page.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 16 Apr 2015, 12:42 PM
Thanks, Marin. That was the issue, the jQuery reference wasn't properly initialized.
Tags
Window
Asked by
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Marin Bratanov
Telerik team
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or