Q3 2013 ScrollView content(...) method error

4 posts, 1 answers
  1. Kevin Kembel
    Kevin Kembel avatar
    48 posts
    Member since:
    Mar 2009

    Posted 26 Nov 2013 Link to this post

    Upgraded to Q3 2013, and I set the content for my scrollview through the content() method, but it's getting a:
    Error: Object doesn't support property or method '_getPages'

    I tried creating just a simple example from the Kendo UI docs, and I still get the error:
    <div id="slideshow">
    </div>
    <script>
        function showHome(e) {
            var slideshow = $("#slideshow").kendoMobileScrollView().data("kendoMobileScrollView");
            slideshow.content('<div data-role="page">Item1</div><div data-role="page">Item2</div>');
        }
    </script>
    This is the exact same content that is set in the API docs for the content(...) method, so I'm leaning towards a bug?
  2. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 27 Nov 2013 Link to this post

    Hello Kevin,

    When the ScrollView is initialized with no content, the widget expects to be later bound to a DataSource. In other words the widget is ready to operate in data bound mode. Since the content method is not supported in data bound mode you receive a JavaScript error.

    The solution is to put a HTML element inside the ScrollView wrapper. Even an empty <div> tag will do the job.
    <div data-role="view" data-init="changePages">
        <div id="scrollView" data-role="scrollview">
            <div></div>
        </div>
    </div>
     
    <script>
        var app = new kendo.mobile.Application();
     
        function changePages() {
            var scrollview = $("#scrollView").data("kendoMobileScrollView");
            scrollview.content('<div data-role="page">Item1</div><div data-role="page">Item2</div>');
        }
    </script>

    On a side note it is unclear what exactly you would like to achieve. If you would like to feed the widget with content at a later point (not during the initialization) then probably it will be easier to bind it to a DataSource.

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Kevin Kembel
    Kevin Kembel avatar
    48 posts
    Member since:
    Mar 2009

    Posted 27 Nov 2013 Link to this post

    Excellent, that works perfectly, thank you very much!

    To respond to your side note, I was loading the content after instead of data-binding because the slideshow created a series of <img /> pages based on an xml file.  I found that binding to it as a datasource would cut the images off (I had to specify the contentHeight property if I used a datasource and template). But the height of my images (and consequently the slideshow) would vary depending on the xml - so I didn't want to set a static contentHeight on init.  

    But, if I init the slideshow, and set the pages using mySlideShow.Content(), then the height of the slideshow would expand to fit the images that it contains.  

    Not sure if this was the intent or not, just a way that I found worked for me. 
  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 28 Nov 2013 Link to this post

    Hi Kevin,

    Thank you for the feedback. I am glad to hear that the suggested workaround fit in your scenario.
    Wish you a great day.

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready