2010-04-23 105 views
2

我正在使用jquery cluetip插件,並試圖找出如何刪除任何打開cluetip對話框,一旦我通過ajax加載新的內容。我要麼停留在仍然顯示在新內容之上的對話框,要麼我試圖修復這些問題的方式實際上會刪除所有將來顯示的提示對話框。jquery cluetip - 清理ajax加載的內容

這是我的代碼,謝謝你的幫助。

在dom準備就緒後,我將cluetip實例化如下。

//activate cluetip 
     $('a.jTip').cluetip({ 
      attribute: 'href', 
      cluetipClass: 'jtip', 
      arrows: true, 
      activation: 'click', 
      ajaxCache: false, 
      dropShadow: true, 
      sticky: true, 
      mouseOutClose: false, 
      closePosition: 'title' 
     }); 

當我加載新內容時,我有以下代碼。我遇到的問題是$('。cluetip-jtip')。empty()阻止打開對話框在任何加載的新內容上,而destroy函數不會刪除任何打開的對話框,而只是破壞當前對象。

 $('.next a').live("click", function(){ 

      var toLoad = $(this).attr('href'); 

      var $data = $('#main_body #content'); 

      $.validationEngine.closePrompt('body'); //close any validation messages 
      $data.fadeOut('fast', function(){ 
       $data.load(toLoad, function(){ 
        $data.animate({ 
         opacity: 'show' 
        }, 'fast'); 
        //reinitialise datepicker and toolip 
        $(".date").date_input(); 
        //JT_init(); 
        $('.hidden').hide(); 
        //scroll to top of form 
        $("html,body").animate({ 
         "scrollTop": $('#content').offset().top + "px" 
        }); 
        //remove existing instance 
        //$('a.jTip').cluetip('destroy'); 
        //remove any opened popups 
        $('.cluetip-jtip').empty(); 
        //reinitialise cluetip 
        $('a.jTip').cluetip({ 
         attribute: 'href', 
         cluetipClass: 'jtip', 
         arrows: true, 
         activation: 'click', 
         ajaxCache: false, 
         dropShadow: true, 
         sticky: true, 
         mouseOutClose: false, 
         closePosition: 'title' 
        }); 
       }); 
      }); 

      return false; 
     }); 

回答

0

您是否試過觸發cluetip關閉打開的對話框?添加此代替使用$('.cluetip-jtip').empty();

$(document).trigger('hideCluetip'); 
+0

感謝您的工作 - 一種享受。我也保留了destroy()行以避免multipl實例 – ted776 2010-04-24 11:03:14