Skip to content Skip to sidebar Skip to footer

How To Open Button Link In New Tab Using Knockout Data-bind

I am trying to use a button to open a link into a new tab. The issue is that I am using a data-bind attr: href and using target='_blank' does not work because the target function r

Solution 1:

You can simply do this:

<a data-bind="attr: {href: '@Url.Action("Data", "Report")/?serialNumber='+SN()}" class="btn btn-warning createNew" target="_blank"> View Report </a>

You can ignore the HTML validation error since the validator does not - and cannot - know about the dynamically added href attribute. It's not a problem.

Post a Comment for "How To Open Button Link In New Tab Using Knockout Data-bind"