Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
Object data attribute updating yet content not changing

I have a vue app that is a mail client. Currently, I'm writing the code to view email attachments -

Below is a snippet from the template and the js

Relevant Template code

<div class="modal-body text-center">
<object style="width:100%; min-height:750px;" id="attachment-preview" v-bind:data="inbox.attachment_data" v-bind:type="inbox.attachment_type"></object>
</div>

Relevant js code

 let b64 = rsp.data; //rsp.data is a base64 encoded string - working properly because the first attachment loaded is fine and others work after issuing a command
 if (attachment.filename.includes('.pdf')) {
    app.inbox.attachment_data = `data:application/pdf;base64,` + b64;
    app.inbox.attachment_type = 'application/pdf';
 }
 else if (attachment.filename.includes('.txt')) {
    app.inbox.attachment_data = `data:text/plain;base64,` + b64;
    app.inbox.attachment_type = 'text/plain';
 }
 // you get the idea

On the first preview everything works fine the attachment is loaded into the preivew accordingly. However, when you attempt to preview the next attachment there is an issue. I see that the data and type attributes are getting set correctly, yet the content shown in the object tag is not updating until I do something like --

document.getElementById("attachment-preview").data = document.getElementById("attachment-preview").data

in the console.

Does anyone have any insight in how I can correct this or why this would be happening?

I feel like I could run this on a timer

document.getElementById("attachment-preview").data = document.getElementById("attachment-preview").data

but I would prefer to not have to do this.

EDIT Eventually, I just gave up and removed the old object and made a new one.

 let object = document.createElement("object");
// set object properties
//remove all children from attachment-preview-holder
while (document.getElementById("attachment-preview-holder").firstChild) {
       document.getElementById("attachment-preview-holder").removeChild(document.getElementById("attachment-preview-holder").firstChild);
 }
document.getElementById("attachment-preview-holder").appendChild(object);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda