2012-05-27 65 views
0

我有以下的jQuery代碼,我用什麼工具提示圖像和火ajax調用請求。直到一個點工作正常,但在div由ajax重新加載後,工具提示和滑塊實際上應該能夠啓動新的ajax調用正在停止工作。jquery不會重新載入後ajax

// Load this script once the document is ready 
$(document).ready(function() { 

// Get all the thumbnail 
$('div.thumbnail-item').mouseenter(function(e) { 

    // Calculate the position of the image tooltip 
    x = e.pageX - $(this).offset().left; 
    y = e.pageY - $(this).offset().top; 

    // Set the z-index of the current item, 
    // make sure it's greater than the rest of thumbnail items 
    // Set the position and display the image tooltip 
    $(this).css('z-index','15') 
    .children("div.tooltip") 
    .css({'top': y + 10,'left': x + 20,'display':'block'}); 

}).mousemove(function(e) { 

    // Calculate the position of the image tooltip 
    x = e.pageX - $(this).offset().left; 
    y = e.pageY - $(this).offset().top; 

    // This line causes the tooltip will follow the mouse pointer 
    $(this).children("div.tooltip").css({'top': y + 10,'left': x + 20}); 

}).mouseleave(function() { 

    // Reset the z-index and hide the image tooltip 
    $(this).css('z-index','1') 
    .children("div.tooltip") 
    .animate({"opacity": "hide"}, "fast"); 
}); 



$(function() { 
    $(".slider").slider({ 
     value:0, 
     min: 0, 
     max: 100, 
     step: 10, 
     change:function(e,ui){ 

      var domain = document.domain; 
      var count = $('#amount').val(); 
      var $parent = $(this).closest(".product_box"); 
      var modul_title = $("h4", $parent).text(); 
      alert(count); 
      $.ajax({ 

       url:'index/ajax', 
       data:{mod_title:modul_title, domain:domain, count:count}, 
       cache:true, 
       datatype:'html', 
       success: function(response) { 
        if(response.status = modul_title) { 
         $parent.fadeOut(); 
         $parent.html(response).fadeIn(); 

        } else 

        { 
          alert("something went wrong!"); 
        } 

        } 

       }); 

     }, 
     slide: function(event, ui) { 
      $("#amount").val(ui.value); 
     } 



    }); 
    $("#amount").val($("#slider").slider("value")); 
}); 

}); 
+0

請記住本地化您的變量 - var x = ....; var y = .....;否則它們將在全局名稱空間中創建並可能會相互作用。 –

回答