0
我有如下所示這個局部視圖:嵌套partialview不刷新
@model ComPost.Core.CommandsAndQueries.Contract.DataContract.FinalizeScreenDTO
<div class="row">
<p>
<table id="ProductTable">
<tr><td>Wijzig Product</td><td><input type="checkbox" id="OverrideCheckox" /></td></tr>
<tr><td>Product</td><td>@Html.DropDownListFor(m => m.DepositProductId , new SelectList(Model.DepositProducts, "DepositProductId", "DepositProductName"),new{id="DepositProductSelect", disabled="disabled", style = "width: 500px;", onchange="CallChangefunc();"})</td></tr>
<tr><td>Reden wijziging</td><td><textarea disabled ="disabled" id="OverrideReason" class="CommentText" cols="150" rows="5">@Model.OverrideReason</textarea></td></tr>
</table>
</p>
@{
Html.RenderAction("DepositProductOrder", "Deposit", new { depositid = @Model.DepositId, depositproductid = @Model.DepositProductId });
}
<p>
<input type="submit" id="FinalizeButton" class="btn btn-default" Visible="false" data-url="@Url.Action("FinalizeDeposit", "Deposit")" data-overview="@Url.Action("Index", "Deposit")" value="Finalize" />
</p>
</div>
在這個partialview我有應該由該行被渲染另一個partialview:
@{
Html.RenderAction("DepositProductOrder", "Deposit", new { depositid = @Model.DepositId, depositproductid = @Model.DepositProductId });
}
嵌套partialview包含一個表格來顯示一些信息。 當我在DropDownList中選擇一個新值時,我會去我的控制器並執行我的操作。 這工作正常。 然後將結果傳遞給我的嵌套partialview。
但結果沒有刷新。我的屏幕仍然顯示我第一次進入該頁面時獲取的信息。
的CallChangefunc看起來像這樣
function CallChangefunc()
{
//TODO : call the post for a Finalize.
var el = document.getElementById('DepositProductSelect');
var url = "/Deposit/DepositProductOrder";
var depositProductId = el.options[el.selectedIndex].value;
var depositId = $("#MainTabs").data("depositid");
$.ajax({
url: url,
type: 'POST',
data: {
depositId: depositId,
depositProductId: depositProductId,
},
dataType: 'html',
success: function (result) { },
error: function (x, t, e) { }
});
}
這是我的控制器上的DepositProductOrder行動代碼:
public PartialViewResult DepositProductOrder(int depositid, int depositproductid)
{
DepositProductOrderDTO depositProductOrderDTO = this.QueriesServiceAgent.Call(s => s.GetDepositProductOrder(depositid, depositproductid));
return PartialView(depositProductOrderDTO);
}
我缺少什麼?
只是你是否'DepositProductOrder'動作是打還是不退還的HTML內容的DIV ??? – 2014-09-25 05:55:11
@Kartikeya:DepositProductOrder正在擊中。所以這工作正常。 – 2014-09-25 05:58:33
確保你的ajax請求正在返回正確的html,並且它會成功回調..只是提醒一下,看看成功,並看看會發生什麼。 – 2014-09-25 06:07:00