【问题标题】:Fadeout and remove a table row is not working together at my asp.net mvc淡出和删除表格行在我的 asp.net mvc 上不能一起工作
【发布时间】:2012-03-10 02:47:32
【问题描述】:

我有以下脚本来淡化然后删除表格行,但它只会删除该行。

function deleteconfirmation() {
    $(this).fadeOut('slow', function () { $(this).remove(); });
    jAlert('The Answer was deleted succsfully', 'Deletion Confirmation');
}

那么是否可以在删除表格行之前将其淡出?如果是,我该怎么做?

编辑:-这是将删除其行的表:-

@foreach (var answer in Model.Answers.OrderBy(a=> a.IsRight))
{
       <tr id =  @answer.AnswersID>

        <td>
            @Html.DisplayFor(modelItem => answer.Description)
        </td>
        <td>
            @Html.DisplayFor(modelItem => answer.Answer_Description.description)
        </td>
        <td>
         @Ajax.ActionLink("Delete", "Delete", "Answer",
        new { id = answer.AnswersID },
          new AjaxOptions
          {
              //OnBegin = "deleteconfirmation1",
              Confirm = "Are You sure You want to delete this Answer ?",
              HttpMethod = "Post",
              UpdateTargetId = @answer.AnswersID.ToString(),
              OnSuccess = "deleteconfirmation",
              OnFailure = "deletionerror"
          })


        </td>
        </tr>
}

【问题讨论】:

  • 哪些浏览器会给您带来问题?
  • ...如果是 IE,请参阅stackoverflow.com/questions/2437026/…
  • IE 和 firefox 都不会淡出,它们只会删除表格行..
  • 我猜有些版本的 IE 不支持 opacity 所以fadeOut 不起作用。
  • 但我在 IE、firefox、chrome 上试过了,但它们都不支持淡出!!!

标签: jquery asp.net-mvc-3 fadeout


【解决方案1】:

试试这个:

$( '.mySelector' ).click( function(){
    var self = this;

    /* look the next line */
    $( self ).fadeOut('slow',function(){
        $( this ).remove();
    });

} );

首先: "$(this)" 是一个对象吗?

试试:

if( $(this).length > 0 )
{
    alert( 'Yes!' );
}else{
    alert( 'No!' );
}

如果不是对象,定义你的对象:

var self = this;
//OR
var self = $( '.mtSelector' );

【讨论】:

  • 感谢您的回复,我尝试了第一个选项,但仍然不会显示淡出..
猜你喜欢
  • 2011-11-06
  • 2012-05-20
  • 1970-01-01
  • 2012-01-06
  • 1970-01-01
  • 2014-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多