lundi 24 août 2015

Serving files with ember data

I have an app that allows a user to view embedded PDFs. Those PDFs are generated by the server, and are displayed on the page using PDFObject. What is the proper way to serve these files? Right now, we simply feed the URL into the PDFObject itself:

components/report-viewer.js

var file_url = 'retrieve_file?file_code=' + report.get('file_code');
var pdf = new PDFObject({
  url: file_url,
  width: '100%',
  height: '600px'
}).embed('#pdf');

However, we need to show some sort of loading indicator while the PDF loads. Ember doesn't recognize it's loading, since the code above appears to bypass the route entirely.

The original code didn't have a route for retrieve_file, so I created one (using ember g route retrieve_file) and added queryParams: 'file_code'. It still completely bypasses it.

Any ideas?

Versions:

Ember:      1.11.3
Ember Data: 1.0.0-beta.18




Aucun commentaire:

Enregistrer un commentaire