2010-06-18 85 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; 
}