How to open dynamically formed hyperlink as Popup

2019-08-10 21:20发布

I am forming the hyperlink using knock out. Now i have to open the link as popup. Please find the code snippet below

 <a data-bind="attr: { href:'/Home/TechnicianData?logId=' + $data.LoginId}">
                                More tests...
                            </a>

标签: knockout.js
2条回答
淡お忘
2楼-- · 2019-08-10 21:38

Not really a knockout question, it's an HTML question, you just happen to be using knockout ;)

<a target="_blank" data-bind="attr: { href:'/Home/TechnicianData?logId=' + $data.LoginId}">
   More tests...
</a>
查看更多
再贱就再见
3楼-- · 2019-08-10 21:48

In that case, I believe the easiest way is binding the "click" event to a function. Like this

<a href="javascript:void(0);" data-bind="click: $root.myFunction">Link Content</a> 

JS

function YourViewModel() {
   var self = this;
   //...
   self.myFunction = function (data) {
       window.open('/Home/TechnicianData?logId=' + data.LoginId);
   };
};
查看更多
登录 后发表回答