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

[Solved] Telerik Extensions and Kendo MVC javascript doesn't work as indicated

0 Answers 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Doug
Top achievements
Rank 1
Doug asked on 22 Jun 2012, 09:30 PM

Has anyone else had this problem?

According to all of the documentation you should be able to access the data for any Telerik Extensions or Kendo control using the following code

var data = $('#id').data('tControlType')

However, I have never actually gotten this code to work. No matter what I do, the "data" function always returns undefined. The control actually works correctly and I am able to get at the control data in a few other ways, such as through the event.sender of any event handlers, but the data function does not work.

I am using the Telerik Script Registrar to include jQuery and other scripts in my page. This currently looks something like this:

@{Html.Telerik().ScriptRegistrar().jQuery(true).jQueryValidation(true)
    .Globalization(true).DefaultGroup(group => group
        .Add("~/Scripts/jquery-ui-1.8.11.js")
        .Add("~/Scripts/jquery.ui.touch-punch.js")
        .Add("~/Scripts/jquery.unobtrusive-ajax.js")
        .Add("~/Scripts/bootstrap-tab.js")
        .Add("~/Scripts/bootstrap-dropdown.js")
        .Add("~/Scripts/kendo/kendo.web.js")
        .Add("~/Scripts/kendo/kendo.aspnetmvc.js")
        .Add("~/Scripts/ui.watermark/ui.watermark.js")
        .Add("~/Scripts/date.js")
        .Add("~/Scripts/jquery.blockUI.js")
        .Add("~/Scripts/jquery.ba-bbq.js")}

And it looks like Telerik is using jQuery 1.7.1 because that is what's in the Telerik Scripts folder. The Telerik version is 2012.1.214 and I am also using the Kendo beta, though I was having the same problem before I included Kendo. The ScriptRegistrar is currently in the <HEAD> tag, because Kendo needs it there, although I have also tried putting it before the end of the <BODY> tag as Telerik Extensions recommends with no effect. I have also confirmed that the problem exists in IE, Firefox, Opera, Safari and Chrome.

Because I'm using the Telerik Script Registrar to include all of the Telerik & jQuery related scripts, I kind of expect that this should "just work". What else could I be doing wrong?

EDIT: Here's one example:

@(Html.Telerik().NumericTextBox().Name("NumericTextBox"))
  
<script type="text/javascript">
$(function() {        
    var data = $("#NumericTextBox").data("tTextBox");
    alert(data); //displays "undefined"
});
</script>
Tags
General Discussions
Asked by
Doug
Top achievements
Rank 1
Share this question
or