0
我搞砸瓦特/ MVC 3有點難以獲得局部視圖正常顯示。在Asp.net MVC 3 RC2中的部分視圖
這裏是我的困境:
在我家/索引視圖我有一個ActionLink的到我的控制器/動作,郵政/創建:
<p>
@Html.ActionLink("Create Post", "Create", "Post")
</p>
<div id="PostCreation">
</div>
我創建視圖是一個基本形式的partialView標題,內容等:
@using (Html.BeginForm())
{
<div>
<fieldset>
<legend>Post Creation</legend>
<div class="editor-label">
@Html.LabelFor(m => m.PostTitle)
</div>
<div class="editor-field">
@Html.TextAreaFor(m => m.PostTitle)
</div>
<p>
<input type="submit" value="Publish" />
</p>
</fieldset>
</div>
}
我添加了一些jQuery來我_Layout.cshtml文件,以捕獲屬性點擊:
<script type="text/javascript">
$(document).ready(function() {
$('a').live('click', function() {
$.get($(this).attr('href'), function (html) {
$('#PostCreation').html(html);
});
});
});
</script>
點擊應該更新主頁/索引視圖中的PostCreation div。
使用firebug我發現,當我逐步瀏覽jQuery時,ParialView會在Home/Index中正確顯示,但是一旦我完成了jQuery函數,它就會呈現一個顯示Post/Create窗體的整個新頁面。
任何幫助表示讚賞。謝謝。