I am using an alert plugin on my website. The alert prompts the user to select on of the multiple options. Something like the image.
The issues is that buttons are generated dynamically like this
var html = "<div id='reject-options'></br> ";
html += "<a href='#' class='button alert small radius' data-bind='click: $root.blacklistOrderForMatch'>" + Texts.Order + "</a> </br>";
The click bind doesn't apply because the bindings are already in place when the website loads. How can I achieve this? Looking forward to hear from you.
答案 0 :(得分:4)
你只需要使用:
ko.applyBindings(self, document.getElementById('reject-options'));
//self is your view model
ko.applyBindings
的第二个参数是您要应用绑定的节点。