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

Empty data('tWindow')

12 Answers 367 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam Gritt
Top achievements
Rank 1
Adam Gritt asked on 03 Aug 2010, 06:46 PM
First, we are using the MVC Contrib portable areas so I am not sure if this is somehow conflicting with the Telerik Window control.

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:
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/jquery-1.4.2.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/MicrosoftAjax.debug.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/MicrosoftMvcAjax.debug.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.common.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.textbox.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.grid.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/MicrosoftMvcValidation.debug.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/MvcFoolproofValidation.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.menu.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.draganddrop.js"></script>
<script type="text/javascript" src="/Paylocity.WebTime/Scripts/telerik.window.js"></script>

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

Sort by
0
Atanas Korchev
Telerik team
answered on 04 Aug 2010, 07:13 AM
Hi Adam Gritt,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Matt
Top achievements
Rank 1
answered on 08 Jan 2011, 04:48 PM
Have you resolved this? If so, how?

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

0
Matt
Top achievements
Rank 1
answered on 08 Jan 2011, 06:45 PM
Looking at the Telerik.Web.Mvc.Examples, if I make the window in the First Look example Visible(false) and then click open I get an invalid argument js error.
0
Damian
Top achievements
Rank 1
answered on 28 Jan 2011, 07:22 PM
Is anyone from Telerik going to reply to any of these 'undefined' Window issues?  I have posted an example (linked to my name) under a different thread that demonstrates the undefined issue.  It seems others have posted on this issue in the past as well, but nothing has been resolved?
0
Alex Gyoshev
Telerik team
answered on 31 Jan 2011, 09:04 AM
Hello Damian,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Damian
Top achievements
Rank 1
answered on 31 Jan 2011, 09:54 PM
Alex,

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
0
Alex Gyoshev
Telerik team
answered on 01 Feb 2011, 10:20 AM
Hi 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Scott R
Top achievements
Rank 1
answered on 14 Jun 2011, 04:37 PM
Just in case anyone else is wondering why jQuery would be loaded twice when you've only included the script reference once - and how to stop this behavior - the Telerik extensions load the jQuery library automatically. So if you've included a jQuery script reference in your page and also a Telerik.ScriptRegistrar then you are experiencing a side-effect of the Telerik extensions - which is loading the jQuery library twice.

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?
0
Atanas Korchev
Telerik team
answered on 14 Jun 2011, 04:56 PM
Hi Scott R,

 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Matt
Top achievements
Rank 1
answered on 22 Mar 2012, 11:04 AM
Damian,

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.
0
Alex Gyoshev
Telerik team
answered on 22 Mar 2012, 12:44 PM
Hello Matt,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Matt
Top achievements
Rank 1
answered on 22 Mar 2012, 03:32 PM
Thanks Alex - the partial view was to blame! It too had a jQuery script tag that hadn't been spotted and removed.
Much appreciated and one to watch!
Tags
Window
Asked by
Adam Gritt
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Matt
Top achievements
Rank 1
Damian
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Scott R
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or