0
我在ASP.NET MVC3中開發,我有下面的代碼來發送包含一些JavaScript的視圖,它將被加載到客戶端的jQuery UI對話框中,但我沒有看到Javascript代碼在客戶端的任何地方,ASP.NET Javascript沒有被髮送到jQuery UI對話框
查看:
@model APS.HelpDesk.Data.App_TaskComment
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Ajax.BeginForm("AllAddComment", new { area = "Task" }, new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "AddCommnetloadingGif",
UpdateTargetId = "AllCommentList" + Model.TaskId,
OnSuccess = " $('#AddCommentDialog').dialog('close');"
}))
{
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.TaskId)
<input type="hidden" value="@Model.TaskId" id="TaskId" />
<div class="editor-label">
@Html.Label("کامنت جديد")
</div>
<div class="editor-field">
<textarea id="CommentText" rows="2" name="CommentText" data-val-required="نوشتن کامنت ضروری است"
data-val="true" cols="20"></textarea>
<br />
@Html.ValidationMessageFor(model => model.CommentText)
</div>
<p>
<input type="submit" value="ارسال" />
</p>
<div id="AddCommnetloadingGif" style="display: none">
<img src="@Url.Content("~/Content/Images/ajax-loader/1.gif")" />
</div>
}
<script type="text/javascript">
$(document).ready(function() {
bkLib.onDomLoaded(function() {
new nicEditor({ iconsPath: '@Url.Content("~/Content/WYSIWYG/nicEditorIcons.gif")' }).panelInstance('CommentText');
});
});
</script>
Dialog的代碼fromFirebug
<div style="outline: 0px; height: auto; width: 500px; position: absolute; top: 385px; left: 379px; display: block; z-index: 1002; " class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-AddCommentDialog"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="ui-dialog-title" id="ui-dialog-title-AddCommentDialog">ايجاد کامنت جديد</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button"><span class="ui-icon ui-icon-closethick">close</span></a></div><div id="AddCommentDialog" style="text-align: right; width: auto; min-height: 108px; height: auto; " class="ui-dialog-content ui-widget-content">
<form action="/Task/Task/AllAddComment" data-ajax="true" data-ajax-loading="#AddCommnetloadingGif" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-success=" $('#AddCommentDialog').dialog('close');" data-ajax-update="#AllCommentList15" id="form0" method="post"><input data-val="true" data-val-number="The field TaskId must be a number." data-val-required="The TaskId field is required." id="TaskId" name="TaskId" type="hidden" value="15"> <input type="hidden" value="15" id="TaskId">
<div class="editor-label">
<label for="">کامنت جديد</label>
</div>
<div class="editor-field">
<textarea id="CommentText" rows="2" name="CommentText" data-val-required="نوشتن کامنت ضروری است" data-val="true" cols="20"></textarea>
<br>
<span class="field-validation-valid" data-valmsg-for="CommentText" data-valmsg-replace="true"></span>
</div>
<p>
<input type="submit" value="ارسال">
</p>
<div id="AddCommnetloadingGif" style="display: none">
<img src="/Content/Images/ajax-loader/1.gif">
</div>
</form>
</div><div class="ui-resizable-handle ui-resizable-n" style=""></div><div class="ui-resizable-handle ui-resizable-e" style=""></div><div class="ui-resizable-handle ui-resizable-s" style=""></div><div class="ui-resizable-handle ui-resizable-w" style=""></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se" style="z-index: 1001; "></div><div class="ui-resizable-handle ui-resizable-sw" style="z-index: 1002; "></div><div class="ui-resizable-handle ui-resizable-ne" style="z-index: 1003; "></div><div class="ui-resizable-handle ui-resizable-nw" style="z-index: 1004; "></div></div>
警報,但我不能看到螢火蟲的警報。 – ePezhman
你在看FireBug?你看我的屏幕截圖中顯示的控制檯選項卡?這是你看到AJAX請求的地方。然後簡單地展開它並分析服務器返回的響應。你會看到腳本。當添加AJAX時,瀏覽器直接解釋內聯腳本。它實際上並沒有將它們添加到DOM,所以如果您使用FireBug探索您的DOM,您將不會看到它們。 –