简体   繁体   English

从父视图调用时,模态弹出窗口未在部分视图中加载

[英]Modal Popup not loading in partial view when calling from parent view

I am trying to call a modal on a partial view from a view but am not getting ajax success call, but dont know how to do it: 我试图从一个视图的部分视图上调用一个模式,但没有得到ajax成功调用,但不知道如何做到这一点:

Here is what i have, javascript ajax code on my page: 这是我的页面上的javascript ajax代码:

var TeamDetailPostBackURL = '/BMApproval/GetMeetingApprovalData';
$(function () {
    $(document).on('click','.LeadCode', function () {
    //$(".LeadCode").click(function () {
        debugger;

        var $buttonClicked = $(this);
        var id = $buttonClicked.attr('data-id');
        var options = { "backdrop": "static", keyboard: true };
        alert("load");

        $.ajax({
            type: "GET",

            url: TeamDetailPostBackURL,
            contentType: "application/json; charset=utf-8",
            data: { "dataValue": id },
            datatype: "json",
            success: function (data) {
                debugger;
                $('#myModalContent').html(data);
                $('#myModal').modal(options);

                $('#myModal').modal('show');

            },
            error: function () {
                alert("Dynamic content load failed.");
            }
        });
    });

And parameters I am passing in ajax call 我在ajax调用中传递的参数

<td><a href="javascript:void(0);" class="LeadCode" data-id="@LPOPoint.LeadCode|@LPOPoint.ApprovalType">@LPOPoint.LeadCode</a></td>

Also calling modal popup in the same javascript page which will popup on the partial view. 还在同一JavaScript页面中调用模式弹出窗口,该页面将在部分视图上弹出。

<div id='myModal' class='modal' style="overflow-y:hidden;">
<div class="modal-dialog" style="overflow-y: scroll; max-height:85%;  margin-top: 20px; margin-bottom:20px;">
    <div class="modal-content">
        <div id='myModalContent'></div>
    </div>
</div></div>

I searched a lot in various forums but couldn't get any solution. 我在各种论坛上进行了很多搜索,但找不到任何解决方案。 When am clicking on html link the popup doesn't load in the partial view. 单击html链接时,弹出窗口不会在部分视图中加载。 And ("Dynamic content load failed."); 和(“动态内容加载失败。”); is displayed as it doesn't get to success. 被显示,因为它没有成功。 Basically I want to view data in modal popup in partial view based on the parameters from parent view. 基本上,我想基于父视图的参数在部分视图的模态弹出窗口中查看数据。 Any help would be appreciated. 任何帮助,将不胜感激。

  1. At the first sight looks like you need TeamDetailPostBackURL variable to contain a proper URL including scheme, host (and port if needed) like 'http://example.com/BMApproval/GetMeetingApprovalData' 乍一看,您需要TeamDetailPostBackURL变量来包含适当的URL,包括方案,主机(和端口(如果需要)),例如'http://example.com/BMApproval/GetMeetingApprovalData'
  2. You can specify error parameter in the error callback to see what exactly is wrong 您可以在错误回调中指定error参数,以查看到底是什么错误

      error: function (error) { console.error(error) alert("Dynamic content load failed."); } 

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

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