Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!