0

我有一个页面列出了员工的培训,以便为每个培训进行调查。我在一个 div 中有多个弹出链接,单击时会打开一个弹出窗口。以下脚本打开弹出窗口。我想在提交调查后用新信息更新弹出链接所依赖的部分,这意味着我只想列出他们的调查不被视为弹出链接的培训。

$(document).ready(function () {
        $('.addSurvey').click(function () {
            $.ajax({
                url: this.href,
                type: 'GET',
                cache: false,
                context: this,
                success: function (result) {
                    $(this).next('.result').html(result).dialog({
                        autoOpen: true,
                        title: 'Anket',
                        width: 500,
                        height: 'auto',
                        modal: true,
                        beforeClose: function (event, ui) {
                            reloadContent();
                        }

                    }); //end of dialog
                } //enf of success function
            }); //end of ajax call
            return false;
        });
    });

要为每个培训创建链接并列出弹出链接,我使用以下页面。

@{if (Model.TrainingList == null || !Model.TrainingList.Any())
  {
    <p>
        Personel için anket bilgisi bulunamadı!</p>
  }
  else
  {

      foreach (var training in Model.TrainingList)
      {
     <table class="surveyTable">
        @{ if (training.Survey != null)
           { 
            <tr>
                <td class="view_detail_label">
                    Eğitim Adı
                </td>
                <td>
                    @(training.Name != null ? @training.Name.Name : "")
                </td>
            </tr>
            <tr>
                <td class="view_detail_label">
                    Eğitim İçeriği ve Programın Değerlendirilmesi Ortalaması
                </td>
                <td>
                    @((training.Survey.Context + training.Survey.Example
                </td>
            </tr>

            <tr>
                <td class="view_detail_label">
                    Eğitimlerin Değerlendirilmesi
                </td>
                <td>
                    @((training.Survey.Knowledge))
                </td>
            </tr>

            <tr>
                <td class="view_detail_label">
                    Eğitim Materyallerinin ve Ortamının Değerlendirilmesi
                </td>
                <td>
                    @((training.Survey.Tool + training.Survey.Source)
                </td>
            </tr>
           }
           else
           {

            <tr>
                <td class="view_detail_label">
                    Eğitim Adı
                </td>
                <td>

                   @Html.ActionLink(
                   training.Name.Name,
                   "AddSurvey",
                   new
                   {
                       employeeId = Model.Id,
                       trainingId = training.Id
                   },
                   new
                   {
                       @class = "addSurvey"
                   }
               )

                  <div class="result" style="display:none;"></div>

                </td>

            </tr>



           }

        }
     </table>
  }

      }
  }

上面的页面是子页面

<script type="text/javascript">
    $('#tab-container').easytabs();


</script>
<div id="tab-container" class="tab-container">
    <ul class="etabs">
        <li class="tab"><a href="#employee_common">Genel Bilgiler</a></li>
        <li class="tab"><a href="#employee_education">Eğitim Bilgileri</a></li>
        <li class="tab"><a href="#employee_work">İş Tecrübesi</a></li>
        <li class="tab"><a href="#employee_other">Kişisel</a></li>

         <li class="tab"><a href="#employee_files">Dosyalar</a></li>

         <li class="tab"><a href="#employee_turnike">Turnike</a></li>
         <li class="tab"><a href="#employee_survey">Eğitim Anket</a></li>


            <li class="tab"><a href="#employee_turnike_report">Kapı Giriş Raporu</a></li>
            <li class="tab"><a href="#employee_training">Kurumsal Eğitimler</a></li>
    </ul>
    <div id="employee_common">
        @{ Html.RenderPartial("_DetailsCommon"); }
    </div>
    <div id="employee_education">
        @{ Html.RenderPartial("_DetailsEducation"); }
    </div>
    <div id="employee_work">
        @{ Html.RenderPartial("_DetailsWork"); }
    </div>

    <div id="employee_other">
        @{ Html.RenderPartial("_DetailsPersonal"); }
    </div>


        <div id="employee_survey">
            @{ Html.RenderPartial("_DetailsSurvey");}
        </div>

我在 _DetailsS​​urvey.cshtml 文件中有以下脚本仅刷新 div 部分,但它不起作用。

function reloadContent() {
        $(document).load(window.location.href + " #employee_survey");
    }

另一个问题是,即使我刷新页面,我的模型也会从控制器刷新吗?

4

1 回答 1

1

关于你的最后一个问题:一旦视图被渲染,真的没有“模型”的概念,所以没有。

将 aconsole.log('Closing');放入reloadContent()函数中;这将告诉您该方法是否被调用。如果您还没有它,请确保您有 Firebug 或 Firebug Lite(取决于您最喜欢的要在其中调试的浏览器)。

这个:

function reloadContent() {
    $(document).load(window.location.href + " #employee_survey");
}

不管用。load()需要一个 CSS 选择器来加载内容;document是一个 DOM 元素。

编辑:让我们尝试利用扩展功能,如另一个问题的答案所示:https ://stackoverflow.com/a/8452751/534109

添加扩展名(就在您的内部某处$(document).ready()):

$.fn.loadWith = function (url) {
    this.load(url, function(response, status, jqxhr) {
        $(this).children(':first').unwrap();
    });
};

在 内调用它reloadContent()

function reloadContent() {
    $('#employee_survey').loadWith (window.location.href + " #employee_survey");
}

看看unwrap()你是否想知道发生了什么。

于 2013-05-28T08:15:05.937 回答