Select a Kendo control generated by helper

2 posts, 1 answers
  1. stephane
    stephane avatar
    10 posts
    Member since:
    Jan 2010

    Posted 16 Jun 2014 Link to this post

    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" })
                    ))
  2. Answer
    Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 16 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top