2010-06-18 115 views
0

我目前正在使用AJAX:UpdatePanelAnimationExtender,我已经在代码后面实现它目前正在完美工作,但我遇到了使用UpdatePanelAnimationExtender和ASP的问题:Repeater 。我一直在搞不同的方式来实现它,但没有任何工作正常... jQuery突出显示与ASP:UpdatePanel


我试图让它写在codebehind - 内itemBound(生成代码完美,附加到UPAE,但当然在部分回传中被丢弃)。 我也试图在aspx中使用它,这也造成了一个问题。
中继器本身正在创建一个项目表(购物车),我试图突出显示发生回发时发生变化的项目(如果数量发生变化,则突出显示qty)。

我读过jQuery有一个更干净的方式做到这一点,并试图去那个方向。
编辑: 我目前看

function pageLoad() 
    { 
     Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
     changedHighlight(); 
    } 
    function EndRequestHandler(sender, args){ 
     if (args.get_error() == undefined){ changedHighlight(); } 
    } 
    function changedHighlight() { 
     $(document).ready(function() { 
      $('span,input,option,select').live('change', function() { $(this).effect("highlight", {color: "#44EE22"}, 1500); }); 
     }); 
    } 

我不得不为它比较储值新发布的值,我的工作现在。另外'改变'似乎不适用于asp:labels?

回答

0

由于每次使用UpdatePanel和DOM重新创建回发问题(意味着无法使用$ .data()或this.data()),因此使用全局var(eh ..)结束。

只会突出显示具有ID的非提交输入和DOM元素。 (否则静态asp:标签将继续闪烁)

var oldVar = []; 
function pageLoad() 
{ 
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler) 
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
} 
function BeginRequestHandler(sender, args) { 
    $(document).ready(function() { 
     oldVar = []; 
     $('input,select,span').each(function() { 
     if (this.type != "submit" && this.id != '') oldVar[this.id] = getValue(this); 
     }); 
    }); 
} 
function EndRequestHandler(sender, args){ 
    $(document).ready(function() { 
     $('input,select,span').each(function() { 
      if (this.type != "submit" && this.id != '') 
      { 
       if (oldVar[this.id] != getValue(this)) 
       { 
        $(this).effect('highlight', {color: '#44EE22'}, 3000); 
        oldVar[this.id] = getValue(this); 
       } 
      } 
     }); 
    }); 
} 
function getValue(control){ 
    if ('value' in control) return control.value; 
    else if('textContent' in control) return control.textContent; 
    else if('innerText' in control) return control.innerText; 
}