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

209
Visualizações
Knockout "html" not rendering target="_blank"

I have a questing about knockout not rendering html attributes properly. I have a span tag that gets populated with data using knockout JS.

<span id="s34" data-bind="html: $parent.Branch.TextComments"></span>

TextComments is dynamic and sometimes contain text only. Other times text and < a> tags. For example:

This is text example of TextComment. Access google at <a href="https://www.google.com/" target="_blank">Goole link</a>. Thank you!

When the page reders, the link reders correctly as a url but when I click it, it doesn't open a new tab, it redirects the page to google instead of opening a new tab which target="_blank" should accomplish.

Any ideas?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I was curious if it really doesnt work.

I set up this minimal code snippet and everything works as expected in my local environment

var system = {
  viewModel:function (data) {
    var self = this;
    self.texts = ko.observableArray([
      "text 21321", 
      'text <a href="https://google.com" target="_blank"> with target blank </a> ',
      'text <a href="https://google.com" > without target blank </a> ',
      'text 789'
    ]);
  }
}

var vm = new system.viewModel();
ko.applyBindings(vm);
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div data-bind="foreach:texts">

 <span data-bind="html:$data"></span> <br>
</div>
<a href="https://google.com" target="_blank"> Test stack-snippet target-blank </a>

So in this snippet the links do also not open correct for me, but maybe this is a snippet restriction. See the normal link i added with target="_blank" it also doesnt open in snippet. in my local environmet all the links with target="_blank" opens in a new tab while the other one does not

about 4 years ago · Juan Pablo Isaza Relatório
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