1

我正在使用 mvcAjax.BeginForm加载其中包含 kendo ComboBox 的局部视图。

在表单的 AjaxOptions 中使用InsertionMode = InsertionMode.ReplaceWith时,一切正常,部分视图加载了 kendo 功能。

但是,当将 InsertionMode 更改为 时InsertionMode = InsertionMode.InsertAfter,会加载部分视图但没有剑道功能,并且我得到一个简单的文本框而不是自动完成组合框。

我已经检查了这两个场景页面源,我可以在它们中看到 kendo jquery 脚本,但它似乎只有在使用 ReplaceWith 时才会被触发。

我正在使用的代码:

@using (Ajax.BeginForm("AddNewPlanDetail", "Plans", new AjaxOptions
{
   UpdateTargetId = "AdditionalPlanDetailsHolder",
   InsertionMode = InsertionMode.InsertAfter,//<--only changed this
   HttpMethod = "Post",
   OnFailure = "handleAjaxError"
}))
{  ......  }

所有其他代码(操作、部分视图)保持不变。

有任何想法吗?

更新:

为了简化问题,我在没有剑道脚本的情况下仅使用简单的 javascript 重建了一个示例:

我的视图索引.chtml:

@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/unobtrusive")
</head>
 <body>
      <div>
        @using (Ajax.BeginForm("GetPartial", "AjaxTest", new AjaxOptions
                        {
                            UpdateTargetId = "updateTargetElement",
                            InsertionMode = InsertionMode.InsertAfter,//<--Change this
                            HttpMethod = "Post"
                        }))
    {
        <h1>
            Ajax Form Test
        </h1>
        <input type="submit" value="submit" />
    }
    <div id="updateTargetElement">
    </div>
</div>

我的控制器:

public class AjaxTestController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [HttpPost]
    public ActionResult GetPartial()
    {
        return PartialView("Partial1");
    }
}

我的部分视图 Partial1.chtml:

<b>This is from partial</b>
<script>
alert('Fired');
</script>

警报脚本被触发,但仅在使用时触发InsertionMode = InsertionMode.ReplaceWith

4

0 回答 0