what is .data() for?

5 posts, 1 answers
  1. Answer
    Cheng-how
    Cheng-how avatar
    26 posts
    Member since:
    Jun 2013

    Posted 06 Jul 2013 Link to this post

    Hi, I'm new to KendoUI, something i not understand is what is the different between

    var slider = $('#slider').kendoSlider().data('kendoSlider');

    and 

    var slider = $('#slider').kendoSlider();

    ?

    what is the .data() method for?

    thanks.
  2. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 08 Jul 2013 Link to this post

    When calling "kendoSlider" on a JQuery object, that object will be converted into a Slider widget, and the JQuery object will be returned. However, calling "data" on a JQuery object will give back the Kendo Slider widget, which must have been created with "kendoSlider" before.

    So your first statement results in a Kendo Slider widget being assigned to the variable. And your second assignment results in a JQuery object being assigned to the variable.

    Michael G. Schneider
  3. Kendo UI is VS 2017 Ready
  4. Cheng-how
    Cheng-how avatar
    26 posts
    Member since:
    Jun 2013

    Posted 08 Jul 2013 Link to this post

    I see..  thanks for your explanation!
  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 08 Jul 2013 Link to this post

    Hi Cheng,


    The data() method is a JQuery method, which is used to store data associated with a specified element. You could also take a look at the following documentation page for additional details.

    I wish you a great day!

     

    Regards,
    Dimiter Madjarov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Cheng-how
    Cheng-how avatar
    26 posts
    Member since:
    Jun 2013

    Posted 08 Jul 2013 Link to this post

    I see.. i'm understand now, thanks..
Back to Top
Kendo UI is VS 2017 Ready