使用Razor引擎在MVC3中进行部分视图渲染后无法打开fancybox。 [英] Unable to open fancybox after partial view rendering in MVC3 using Razor engine.
问题描述
@using (Ajax.BeginForm("_SubmitComment", "Blogs", new AjaxOptions
{
UpdateTargetId = "comments",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure",
LoadingElementId = "loading",
OnBegin = "onSubmitBegin",
InsertionMode = InsertionMode.Replace
}))
{ <!-- comment box -->
@Html.AntiForgeryToken()
<div class="comment-box">
<h3>
Comments</h3>
@if (@ViewData["StatusMessage"] != null && @ViewData["StatusMessage"].ToString().Trim().Length > 0)
{
<p class="graymessage" id="messagearea">
@ViewBag.StatusMessage.Trim()</p>
}
<ul>
@foreach (var comment in Model.comment)
{
<li>
<p>
@comment.CommentByName says</p>
<span>@comment.CommentDate at @comment.CommentTime</span>
<p>
@comment.Content
<br class="cl" />
<br class="cl" />
@if (!(@comment.IsAbused))
{
<a id="@comment.commentid.ToString()" önclick="javascript:GetMyID(this);"
style="text-decoration: none; color: blue; removed: pointer;" href="#inline1" class="various21"><!--Open Fancybox on click of this link-->
Report Abuse</a>
}
else
{
<a önclick="javascript:AlreadyMarked();" style="text-decoration: none; color: blue;
cursor: pointer;">Report Abuse</a>
}
</p>
</li>
}
</ul>
<div class="cl">
</div>
<script type="text/javascript">
$(document).ready(function () {
$(".various21").fancybox();
});</script> </div>
它正在第一次在页面加载时工作,但在提交部分视图并从控制器获得响应后不久,花式框无效。我试图在ajax.Beginfarm的OnSuccess上绑定fancybox代码,但仍然没有帮助。
It is working on first time on page load, but soon after submitting the partial view and getting response from controller, fancy box is not working. i tried to bind the fancybox code on "OnSuccess" of ajax.Beginfarm, but still no help.,
function OnSuccess() {
try {
$(".various21").on("click", function (args) {
GetMyID(this);
alert("heelll");
fancybox()
});
$(".various2").on("click", function (args) {
alert("heelll");
GetMyID(this);
fancybox()
});
$(".various2").on("click", function (args) {
alert("heelll");
GetMyID(this);
fancybox()
});
$(".various21").on("click", function (args) {
alert("heelll");
GetMyID(this);
fancybox()
});
} catch (ee) {
alert(ee.Message);
}
}
可能是因为语言或方式放置这些问题而无法理解您的问题所以请提出您的问题与此有关。我很感激。
我在做一些代码以及输入这个问题。
may be this question is not understood to you due to the language or way to put the things, So please raise your questions relating this. I appreciate this.
I doing some code as well typing this question.
推荐答案
(文档)。ready( function (){
(document).ready(function () {
( 。various21)。fancybox();
}); < / script > < / div >
(".various21").fancybox(); });</script> </div>
它首次在页面加载时工作,但在提交部分视图并获得响应后不久控制器,花式盒子不工作。我试图在ajax.Beginfarm的OnSuccess上绑定fancybox代码,但仍然没有帮助。
It is working on first time on page load, but soon after submitting the partial view and getting response from controller, fancy box is not working. i tried to bind the fancybox code on "OnSuccess" of ajax.Beginfarm, but still no help.,
function OnSuccess() {
try {
( 。various21)。on( 点击, function (args){
GetMyID( this );
alert( heelll);
fancybox()
});
(".various21").on("click", function (args) { GetMyID(this); alert("heelll"); fancybox() });
这篇关于使用Razor引擎在MVC3中进行部分视图渲染后无法打开fancybox。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!