2010-04-23 107 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