在AJAX更新后,输入不会得到焦点。 IE7

时间:2011-06-10 14:04:27

标签: jquery asp.net-mvc ajax

我有一个包含多种表单的页面。用户可以修改内容,所有请求都通过AJAX完成。每个AJAX调用都会更新页面的一部分,其中包含一个表单。

更新后,所有输入表单都无法获得焦点。这种情况只发生在IE中,我在Chrome中尝试过,它运行得很好。

任何想法??

编辑:

控制器

[HttpPost, ValidateInput(false)]
        public ActionResult SaveRiskAndRewardItem(int RiskAndRewardItemId, short RiskAndRewardRating, string Description)
        {
            RiskAndRewardItem model = RiskAndRewardItemModelBuilder.GetInstance().BuildOne(RiskAndRewardItemId);

            model.RiskAndRewardRating = RiskAndRewardRating;
            model.Description = Description;
            if (ModelState.IsValid)
            {
                _riskAndRewardItemRepository.Update(model);
            }
            return PartialView("_RiskAndRewardItem", model);
        }

查看

@model KII.Models.RiskAndRewardItem
<div data-risk-and-reward-item-id="@Model.Id">
    <span class="editContentLink actionLink" data-risk-and-reward-item-id="@Model.Id" data-viewer="viewrisk-and-reward-item-@Model.Id" data-editor="editrisk-and-reward-item-@Model.Id">Edit</span>
    <div id="viewrisk-and-reward-item-@Model.Id">
        <table class="riskAndRewardTable">
            <tr data-risk-and-reward-item-id="@Model.Id">
                @for (int i = 1; i < 8; i++)
                {
                    <td class="risk-and-reward-item @((i == @Model.RiskAndRewardRating) ? "risk-and-reward-item-selected" : "")">@i
                    </td>
                }
            </tr>
        </table>
        <div style="display: inline">
            <div style="float: left">
                lower rewards/risk
            </div>
            <div style="float: right">
                higher rewards/risk
            </div>
            <br />
            <br />
        </div>
        <div data-risk-and-reward-item-id="@Model.Id">
            @Html.Raw(@Model.Description)
        </div>
    </div>
    <div id="editrisk-and-reward-item-@Model.Id" style="display: none;width:100%">
        @using (Ajax.BeginForm("SaveRiskAndRewardItem", null, new AjaxOptions
        {
            UpdateTargetId = "itemContent-" + @Model.Item.Id,
            HttpMethod = "POST",
            InsertionMode = InsertionMode.Replace,
            OnBegin = "loading(\"itemContent-" + @Model.Item.Id+"\")",
            OnSuccess = "loaded(\"itemContent-" + @Model.Item.Id+"\")",
        }, new { @id = "TitleForm" }))
        {

            <table class="riskAndRewardTable">
                <tr data-risk-and-reward-item-id="@Model.Id">
                    @for (int i = 1; i < 8; i++)
                    {
                        <td class="risk-and-reward-item-edit @((i == @Model.RiskAndRewardRating) ? "risk-and-reward-item-selected-edit" : "")">@i
                        </td>
                    }
                </tr>
            </table>

            <br />

            <input id="RiskAndRewardItemId" name="RiskAndRewardItemId" type="hidden" value="@Model.Id" />
            <input id="RiskAndRewardRating" name="RiskAndRewardRating" type="hidden" value="@Model.RiskAndRewardRating" />
            <textarea id="Description" class="htmleditor" name="Description" rows="5" cols="40">@Model.Description</textarea>
            <div style="text-align: right">
                <input id="titleButton" type="submit" class="button" value="Save" /></div>
        }
    </div>
</div>

我喜欢4种不同的局部视图,每种视图在控制器中都有自己的方法。就像上面那个。

0 个答案:

没有答案