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

Using Responsive Images in a Native App

1 Answer 28 Views
JavaScript SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy
Top achievements
Rank 1
Andy asked on 08 Oct 2015, 09:54 PM

I would like to use responsive images in a Native app (not Hybrid), but all the samples and examples I can find are only in Hybrid apps.

When I try using the code from the Hybrid app example in a Native app I get an error.

My app has a single view called main-page, and in the main-page.js file I have added the following:

var vmModule = require("./main-view-model");
var Everlive = require('./everlive.all.min');
function pageLoaded(args) {
    var page = args.object;
    page.bindingContext = vmModule.mainViewModel;
    
    var el = new Everlive('my-api-key-is-here');
    el.helpers.processAll();
}
exports.pageLoaded = pageLoaded;

 

In my main-view.xml I have a single image with data-src and data-responsive:

<Image data-src="https://my-image-url-is-here" data-responsive />​

The error I get is 'Cannot read property 'processAll' of undefined'

I'm guessing this is because I'm creating a Native app, and the helper is for html/Hybrid apps.

Does anyone know whether you can use Responsive Images in the same way in Native Apps.

Thanks

1 Answer, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 12 Oct 2015, 03:15 PM
Hello Andy,

Indeed, the HTML Helpers for Responsive Images would work only with DOM elements. I'd suggest that you use the platform-independent approach via the server API and dynamically set as a source of the image the URL of the resized image as explained here.

For instance, a similar approach is used for the native iOS example.

Let me know if you have questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
JavaScript SDK
Asked by
Andy
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Share this question
or