Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda