简体   繁体   English

使用Knockout.js在模式弹出窗口中打开部分视图

[英]Open Partial View in Modal Popup using Knockout.js

I have partial View AssetList loaded with viewmodel usning knockout.js 我有部分视图AssetList加载了使用带有击倒.js的viewmodel

 <td> 
    <div class="left CursorP ellipsis" style="float: left;" data-bind="text: 
     Name, attr: { 'title': Name },click:$root.eventHandlers.ViewDetail"></div>


</td>
<td data-bind="text: Description"></td>
<td data-bind="text: Source"></td>
<td data-bind="text: CapturedBy"></td>
<td data-bind="text: Status"></td>
<td data-bind="text: LastAccessedBy"></td>

In .JS File I need to open the _AssetDetail partial view on click of Name Link 在.JS文件中,我需要单击“名称链接”以打开_AssetDetail部分视图

this.ViewDetail = function () { this.ViewDetail = function(){

       self.SelectedAssetTodelete.removeAll();
        self.SelectedAssetTodelete.push(this);
       window.location =  "#assetId=" + this.Id; --This is opening the Partial view correctly but in the same tab
     };

The Link [assetDetailPage] is Secure/Content/Catalog/Detail?assetId=" + this.Id 链接[assetDetailPage]是Secure / Content / Catalog / Detail?assetId =“ + this.Id

Instead of the same window[window.location] , How we can open Modal Popup using this link inside ViewDetail Function above? 而不是相同的window [window.location],我们如何使用上面的ViewDetail函数中的此链接打开Modal Popup?

you can use iframe tag to load outside content. 您可以使用iframe代码加载外部内容。

<iframe width="300" height="300"
  data-bind="attr: { src: 'Secure/Content/Catalog/Detail?assetId=' + Id }"></iframe>

I don't know your model structure, you may need to replace Id with Id() or $parent.Id() . 我不知道您的模型结构,您可能需要将Id替换为Id()$parent.Id()

You can do it like this using jquery 您可以使用jquery这样操作

<iframe width="300" height="300" id="model"
    data-bind="
        attr: { src: $root.LoadModel(Id) }
"></iframe>


self.LoadModel = function(id){
    var location = 'Secure/Content/Catalog/Detail?assetId='+id
    $('#model').load(location)
    return location
}
  • I Want open the Popup with the same Secure/Content/Catalog/Detail?assetId=' + Id on Name link click on Grid; 我要使用相同的Secure / Content / Catalog / Detail?assetId ='+名称ID链接打开弹出窗口,然后单击Grid; not load the IFrame. 无法加载IFrame。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM