2012-02-14 41 views
0

我們正在嘗試創建一個自定義cms,其中當在標記內部放置rel屬性和目標位置時,它會自動附加一個可以從指定位置rel標籤。再次新的內容(通過ajax來)可以有錨標籤與rel屬性。如何在不使用回調的情況下在ajax調用之後執行點擊處理程序

我怎麼能實現它,而無需使用回調
當前代碼

$(document).ready(function(e) { 

$("a[rel $= txt]").each(function(index, element) { 
     $(this).click(function(){ 


      var path = $(this).attr("rel"); 
      path = "./"+path; 

      var target = $(this).attr("data-target") 


      $(target).load(path, function(){  
       $("a[rel $= txt]", this).each(function(){ 
        $(this).click(function(){ 
         var path = $(this).attr("rel"); 
          path = "./"+path; 
          $("#result").load(path,function(){ 
           $.getScript("js/common.js") 
           }); 

         }) 
        }); 
       $.getScript("js/common.js"); 

       }) 
      })//click ended 

    }); 

}) 
+0

你有一些示例HTML嗎?而且,你使用的是什麼版本的jQuery? – 2012-02-14 14:33:11

+0

錨點就像 Home 持有者就像

  • 2012-02-14 14:41:50

    回答

    0

    您可以使用$(match-expression).live('click',function(){})的點擊處理程序附加到所有匹配的元素,即使是那些創建動態更新版本。在您的情況下,$("a[rel $= txt]").live('click',function(){})將允許您將點擊處理程序附加到所有匹配的錨點。

    相關問題