
I am creating my Window in the page as such:
<% Html.Telerik().Window()
.Name("LaborLevelEdit")
.LoadContentFrom("Edit", "LaborLevel", new { area = "Shared" })
.Draggable(true)
.Resizable(resize => resize.Enabled(true))
.Visible(false)
.Render(); %>
On the page I have a button that executes the showPopup method as detailed below:
<script type="text/javascript">
function getWindow() {
var window = $('#LaborLevelEdit').data('tWindow');
return window;
}
function showPopup() {
var window = getWindow();
if (window) { window.open(); } } </script>
However, when I click the button nothing happens. Upon examining the code using Chrome's Developer Tools I am seeing that the call $('#LaborLevelEdit').data('tWindow') is returning null. I set a breakpoint on the document.ready call to initialize the window and if I check the value after initialization then it has a value but somewhere after this it loses the data value. It works fine if I redirect to the URL within an iFrame but I would prefer to not use an iFrame. The page I am displaying has several Telerik Grids on it but I made sure that when I load the javascript for the main page that it includes the required javascript for the child page as well. As such my javascript statements are as follows:
Any ideas as to why the data('tWindow') is getting cleared out? I did check and made sure that I was not using the same id for another control on the parent window or the child window.
12 Answers, 1 is accepted
We are not aware of any problems caused by mvccontrib's portable areas. Could you please open a support ticket and attach a sample project demonstrating your problem? We are having hard time to guess what may be causing it just based on the description.
All the best,
Atanas Korchev
the Telerik team

I have the same problem and I am not using MvcContrib. I have downloaded the example project 224787_telerikwindowmvcapplication1.zip and added the following to index.aspx:
<% Html.Telerik().Window()
.Name("Window")
.LoadContentFrom("About", "Home")
.Visible(false)
.Modal(true)
.Draggable(true)
.Buttons(buttons => buttons.Refresh().Maximize().Close())
.Width(500)
.Height(600)
.Scrollable(true)
.Render();
%>
with this at the end of index.aspx....
<% Html.Telerik().ScriptRegistrar()
.DefaultGroup(defGroup => defGroup
.Add("telerik.common.js")
.Add("telerik.draganddrop.js")
.Add("telerik.window.js"))
.OnDocumentReady(() => { %>
$('#delete-internet')
.click(function() {
clickButton()
});
<% }); %>
the clickButton() is simply $("#Window").data("tWindow").center().open(); which fails because data is undefined. If I call $("#Window").show() it displays at the bottom of the page however I thought you could get a handle on the client side object so that refresh(), center() and open() methods would be available?
What am I missing?
Thanks
Matt


This error is to load jQuery twice, thus removing all client code of the telerik extensions (because it resides in $.telerik). Another common pitfall is to load a whole view through LoadContentFrom, which renders the Master page, too (which in turn contains the jquery script).
This is indeed a common pitfall, we'll be documenting it right away.
Greetings,
Alex Gyoshev
the Telerik team

I can't tell from your reply if this is an issue that you've been able to replicate and will be posting a follow-up with how to correct/workaround it or if it will just be something that you'll be documenting as a known issue to be fixed sometime in the future.
Thanks for any additional information,
Damian
I meant that jQuery should not be loaded twice. This is a known problem and won't be fixed in the components -- it should be addressed in client code.
Regarding your specific example, you are not rendering the window - you should either call Render() if you are using a code block (<%), or use a server expression (<%=). Right now, you are initializing and building it, but it is not written in the HTML.
Please do not post unrelated questions to other people's threads like the "Window content" thread. You can create new forum threads or at least refer to ones that experience the same problem. Be aware that support is not guaranteed for customers without a commercial license.
Kind regards,
Alex Gyoshev
the Telerik team

To solve, you can either remove the jQuery script reference from your page or disable automatic jQuery loading by Telerik. Removing the script reference doesn't work for me because it is loaded in the master page and used by many pages. The Telerik extensions are only used on a few pages. To disable automatic jQuery loading by Telerik just include this at the bottom of your page:
@(Html.Telerik().ScriptRegistrar().jQuery(false))
I'm curious why Telerik can't automatically determine if jQuery has already been loaded and, if so, don't do it again?
The ScriptRegistrar works entirely on the server side and thus cannot determine if the jQuery JavaScript file (and the right version) has been already included elsewhere without parsing the output of the entire page. The latter is not really an option due to performance reasons.
Regards,Atanas Korchev
the Telerik team

I'm new to Telerik and experiencing exactly the same issue. We've stopped jQuery being loaded twice by removing our standard script references and having Telerik load it for us.
I create a new Window with visible(false) as below:
@{Html.Telerik().Window()
.Name(
"AddIngredientWindow")
.Title(
string.Format("Add new item to the {0}", Model.Name))
.Modal(
true)
.Width(800)
.Height(600)
.Draggable(
true)
.LoadContentFrom(
"PickIngredient", "StoreCupboard", new { recipeFoodItemId = ViewBag.RecipeFoodItemId })
.Effects(fx => fx.Toggle())
.Visible(
false)
.Render();
}
and then use the following to try and show it:
@{ Html.Telerik().ScriptRegistrar()
.OnDocumentReady(@<text>
$('#ShowAddNew').click(
function(e) {
e.preventDefault();
var window = $('#AddIngredientWindow');
window.data('tWindow').center().open();
});
</text>);
}
(apologies - cut and paste has messed the formatting some)
When debugging the javascript the window item exists (and I can cheat and do a window.show()), but the data('tWindow') is undefined and we therefore can't interact with the window 'properly'.
Please advise ASAP as we're evaluating Telerik for a new project and in general love it, but if we can't get this solved we won't be able to justufy buying for the team.
We are not aware of such an issue. Verify that no partial views that load jQuery asynchronously are included, or see whether there are multiple jQuery references on the page. If that doesn't lead you to the problem, please submit a sample solution that shows the issue, so that we can find the problem.
Greetings,Alex Gyoshev
the Telerik team

Much appreciated and one to watch!