2012-02-07 2 views
0

다음 코드는 마우스 오버시 툴팁을 생성하는 코드입니다. 예를 들어 다음 코드를 사용하여 텍스트 위에 마우스를 올려 놓습니다.jQuery/Ajax - IE가 외부 파일에서 데이터를 가져 오지 않습니까?

span class="ttip" rel="#tip_1" 

그런 다음 외부 파일 (tooltips.html)에서 tip_1의 ID로 div를 가져옵니다. 문제는 IE 7에 & 8 - 그냥 툴팁 상자를로드 -하지의 내용을 내부 ...

어떤 아이디어를 (가 tooltips.html 파일과 통신 할 수처럼)하세요?

<script type="text/javascript"> 
    jQuery(document).ready(function(){ 
     jQuery('.ttip').hover(function(){ 
      var offset = jQuery(this).offset(); 
      console.log(offset) 

      var width = jQuery(this).outerWidth(); 
      var tooltipId = jQuery(this).attr("rel"); 

      jQuery('#tooltip-cont').empty().load('/tooltips.html ' + tooltipId).fadeIn(500); 
      jQuery('#tooltip-cont').css({ top:offset.top, left:offset.left + width + 10 }).show(); 
     }, function(){ 
      jQuery('#tooltip-cont').stop(true, true).fadeOut(200); 
     }); 
    }); 
</script> 
+0

코드가 좋을 것 같습니다. – mgraph

+0

내 생각은 일부 툴팁이 작동하지 않기 때문에 실제 toltips.html 파일에 뭔가있는 것 같습니다. – CodeyMonkey

+0

'fadeOut'과' fadeIn' 다음 테스트 – mgraph

답변

1

이 질문을 게시하면서 전치 오류가 아니라면, 당신은 (.html 후) 귀하의 URL에 여분의 공간이 :

.load('/tooltips.html ' + tooltipId) 

아마해야합니다 :

.load('/tooltips.html' + tooltipId) 

관련 없음 : 해당 코드에서 비효율적 인 재 쿼리가 많이 발생합니다. 이미 쿼리 된 요소에 대한 참조를 저장하고 가능한 경우 jQuery의 체인 특성을 사용해야합니다.

관련 문제