在按钮单击时将动作结果附加到模态div

时间:2014-07-11 09:38:59

标签: javascript jquery asp.net-mvc twitter-bootstrap asp.net-mvc-4

我试图将部分视图的动作结果附加到按钮上的模态弹出div 点击

这是脚本;

Function Edit(ID) {
    debugger

    $('#basicModal1').load('@Url.Action("Edit", "Resource")', "&id=" + codeURIComponent(ID))

  }

在按钮上单击我调用该函数并将参数传递给它。

模态弹出

<div  class="modal fade" id="basicModal1" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">

<div class="modal-dialog" style="margin:90px 0 0 360px">     

        <form style="height:440px;width: 500px;background-color:white" class="form">
        <div class="modal-header popup_back" >

        <h4 class="modal-title" id="myModalLabel1">Edit</h4>
        </div>

        <div class="modal-">
          <fieldset id="EditField" class="account-info" style="margin-top:-20px" >

        </fieldset>

        </div>
             <fieldset class="account-action">

//here i like to place the partial view result 

         </fieldset>
         </form>
        @*<div class="modal-footer">

    </div>*@

paritalviewaction正在执行,但弹出窗口没有显示......

1 个答案:

答案 0 :(得分:0)

你应该在加载事件之后添加modal.show事件,例如;

$( "#result" ).load( "ajax/test.html", function() {

    console.log( "Load was performed." );
    // show modal with modal show/hide method

});

为您的例子:

$('#basicModal1').load('@Url.Action("Edit", "Resource")', "&id=" + codeURIComponent(ID),
    function(){
        // modal.show
    });