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

Q3 2013 ScrollView content(...) method error

3 Answers 18 Views
ScrollView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Kevin Kembel
Top achievements
Rank 1
Kevin Kembel asked on 27 Nov 2013, 12:08 AM
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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 27 Nov 2013, 02:24 PM
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!
0
Kevin Kembel
Top achievements
Rank 1
answered on 27 Nov 2013, 10:23 PM
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. 
0
Alexander Valchev
Telerik team
answered on 28 Nov 2013, 10:11 AM
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!
Tags
ScrollView (Mobile)
Asked by
Kevin Kembel
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Kevin Kembel
Top achievements
Rank 1
Share this question
or