I'm working on building out a modal for a web app and part of that involves allowing the user to select different sections of a manual and display that section. The sections are all PDF documents, if that matters. I know that we are quite behind on the latest versions of Ember (1.8.1) and Handlebars (1.3.0), but this is what we have to work with for the time being.
The issue revolves around either not having anything show up or getting a Javascript error, usually with it trying to use "#toolbar=0&navpanes=0&scrollbar=1&toolbar=1" as the URL. How is this supposed to be done? I've checked the value of fileUrl after supposedly setting it and it shows up as an empty string.
Here is what I have in the template that kicks off the process:
{{#each section in details.contents.manual}}
<tr>
<td>{{section.sectionNumber}}</td>
<td><a href="_blank" {{action "readManualSection" section.sectionNumber}}>{{section.description}}</a>
<td>{{section.status}}</td>
<td>{{section.reviewTime}} {{i18n "certification__sections_minutes"}}</td>
</tr>
{{/each}}
And the following is the section of the template for displaying the embedded PDF document:
{{#if readManual}}
<p class="title">Title</p>
<div class="content">
<div class="embeddedManual">
<embed src="{{unbound fileUrl}}#toolbar=0&navpanes=0&scrollbar=1&toolbar=1" width="100%" height="600">
</div>
</div>
{{/if}}
Here is the piece of the Controller that covers the action:
readManualSection: function (sectionNumber) {
var sections = this.get('details.certification.manual'),
fileUrl = '';
for (var i = 0; i < sections.length; i++) {
if (sections[i].sectionNumber == sectionNumber) {
fileUrl = sections[i].location;
}
}
//Application.InformationModal.fileUrl = this.get('fileUrl'); <-- Doesn't seem to set anything
//Application.InformationModal.set('fileUrl', fileUrl); <-- "Application.InformationModal.set is not a function" message
this.set('readManual', true);
this.set('showingManuals', false);
this.set('showCertStatus', false);
}
And here is the piece of the Model:
Application.InformationModal = Application.Model.extend({
fileUrl: '',
});
Aucun commentaire:
Enregistrer un commentaire