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

Select a Kendo control generated by helper

1 Answer 26 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
stephane
Top achievements
Rank 1
stephane asked on 16 Jun 2014, 12:37 PM
When I generate a kendo control  thanks to Jquery, it is easy to select and put it in a javscript var  for doing stuffs on it
@section scripts
{
    <script>
        $(document).ready(function () {
 
              var slider = jQuery("#slider").kendoSlider({
                increaseButtonTitle: "Right",
                decreaseButtonTitle: "Left",
                showButtons: true,
                min: 1,
                max: 4,
                largeStep: 1,
                tooltip: {
                    enabled: false
                }
            });
 });
  </script>
}
 
<input id="slider" class="sliderClass" />
I would like to be able to select the same kendo control generated by the helper way, and put it  in javascript var but i can't manage to do it . Any ideas??????
@section scripts
{
    <script>
 
       var slider = $(".balSlider").kendoSlider; //want to select the kendo control and put it in a  var  but FAIL!!!
   </script>
}
 
 @(Html.Kendo().Slider()
                  .Name("titio")
                  .IncreaseButtonTitle("Right")
                  .DecreaseButtonTitle("Left")
                  .Min(0)
                  .Max(3)
                  .SmallStep(1)
                  .Value(0)
                           .Events(events => events
                      .Slide("sliderSlide")
                     )
                  .HtmlAttributes(new { @class = "balSlider" })
                ))

1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 16 Jun 2014, 12:49 PM
Hello Stephane,

As this article outlines, you need to use the jQuery's data method to reference the client object of Kendo UI widgets.

Also note that the script tag should be placed after the widget's MVC initialization code to ensure it has been instantiated when you reference it in javascript. 

Regards,
Sebastian
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
General Discussions
Asked by
stephane
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or