我正在尝试实现这样的结果,即当用户单击链接时,会打开一个带有 html 的内联花式框。当用户输入一个值并点击输入时,它应该更新(淘汰)我的视图模型,并且花哨的盒子应该面向一个方向。
到目前为止,这是我的代码,我知道我需要重新应用 mybindings 但不知道如何。
HTML:
<div style="display:none">
<div id="inlineManufacturerAdder">
<div style="width:1000px;">
<!-- In deze div alle content -->
<h2>Add new Manufacturer2</h2>
<p>
<form data-bind="submit: vm.addManufacturer">
<input type="text" data-bind="value: vm.newManufacturer, valueUpdate: 'afterkeydown'" placeholder="New Manufacturer">
</form>
</p>
</div>
</div>
</div>
Javascript(打字稿):
export function viewAttached() {
$("a.fancybox-link-add-manufacturer").click(function (e) {
$.fancybox({
content: $('#inlineManufacturerAdder').html(), //this is where it goes wrong, it gets the content and forgets the bindings I guess!
type: 'html'
});
return false;
});
}
如果我以正常方式使用 div(设置为 display:none),那么没有fancybox,一切正常。
我应该怎么办?我正在使用杜兰达尔!