Fancybox与淘汰赛后重新绑定

问题描述:

我试图完成的结果是,当用户点击一个链接内联fancybox用html打开它。当用户输入一个值并点击输入时,它应该更新(敲除)我的视图模型,并且该花式框应该面对一个方法。Fancybox与淘汰赛后重新绑定

这是我的代码到目前为止,我知道我需要重新申请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(也被设置为显示:无)在一个正常的方式,使没有的fancybox一切正常正好。

我该怎么办?我正在使用杜兰达!

+0

我知道我没有回答你的问题,但是,为什么你要使用fancybox? Durandal具有显示模式对话框的功能,甚至包含显示如何更改方面的文档(http://durandaljs.com/documentation/Showing-Message-Boxes-And-Modals/),你需要什么从fancybox,可以杜伦达尔会做什么? – 2013-03-21 13:08:02

您不应该需要重新应用绑定。只是不要传入innerHTML内容,而是将元素节点(或jQuery实例)传递给花式框。

EG:相反的:

content: $('#inlineManufacturerAdder').html()

只是做:

content: $('#inlineManufacturerAdder')

[更新]

或东西长这些行:

<a href="#inlineManufacturerAdder" class="fancybox-link-add-manufacturer" >Click me</a> 
<div id="inlineManufacturerAdder" data-bind="html: msg"></div> 

<script> 
$(".fancybox-link-add-manufacturer").fancybox(); 
</script> 

示例:http://jsfiddle.net/r83XF/2/

+0

如果我这样做,我的打字稿不再编译。它说:提供的参数不匹配呼叫目标的任何签名。 http://postimg.org/image/wu0rfagd3/ – 2013-03-21 11:29:36

+0

好的,我已经使用其他解决方案更新了我的帖子。 – badsyntax 2013-03-21 11:53:40

+0

对不起,没有做到这一点,因为如果链接有href它的sents回到家里! - > http://*.com/questions/15503981/single-page-application-and-inline-fancybox-not-working-properly – 2013-03-21 12:48:18