2014-10-21 3 views
0

부트 스트랩 Popover에 문제가 있습니다. 언젠가는 작동하지만 다른 때는 작동하지 않습니다. 방문자가 사용자 이름을 가리키면 사용자 정보가 포함 된 팝업을 생성합니다. 페이지는 아약스에 의해 생성되었으므로 처음에는 단순히로드되는 컨텐츠의 문제라고 생각했지만 문제는 때로는 작동한다는 것입니다.부트 스트랩 Popover가 일관되게 작동하지 않습니다.

$(document).on('mouseenter', '.postusername', function(e){ 
    var userid = this.parentElement.parentElement.children[0].innerHTML; 
    var te = this; 
    if(userid) 
    { 
     $.get('/Requests/getuinfo.php', {id : userid}) 
     .done(function(data){ 
      var uinfo = JSON.parse(data); 
      boo = uinfo; 
      $(te).popover({ 
       html : true, 
       template : '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>', 
       content : '<div class="popover-holder" style="background-image:url(\'/Style/Media/CoverPics/' + uinfo.coverpic + '\');">' + uinfo.name 
       + '</div>', 
       placement: 'auto' 
      }); 
      $(te).popover('show'); 
     }); 
    } 
}); 

$(document).on('mouseleave', '.postusername', function(e){ 
    $(this).popover('hide'); 
}); 

내가 사용하는 자바 스크립트입니다.

+0

숨긴 후 팝업 제거를 시도 했습니까? 아니면 자동으로 수행 했습니까? – Archer

+0

그게 효과가 있습니다! THANKS SO MUCH @Archer – TheSabby

+0

걱정할 필요가 없습니다 :) – Archer

답변

1

이미 알게되었지만 이미 완료되었을 때 뭔가 새로운 팝업을 만들려고한다는 것이 문제였습니다. 그것을 숨긴 후에 popover를 제거하면 그 문제가 해결되었습니다. 그것은 당신이했습니다 사용자 ID의 배열을 유지

var userids = []; 

$(document).on('mouseenter', '.postusername', function(e){ 
    var userid = this.parentElement.parentElement.children[0].innerHTML; 
    var te = this; 
    if(userid) 
    { 
     if (userids.indexOf(userid) === -1) { 
      $.get('/Requests/getuinfo.php', {id : userid}) 
      .done(function(data){ 
       var uinfo = JSON.parse(data); 
       boo = uinfo; 
       $(te).popover({ 
        html : true, 
        template : '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>', 
        content : '<div class="popover-holder" style="background-image:url(\'/Style/Media/CoverPics/' + uinfo.coverpic + '\');">' + uinfo.name 
        + '</div>', 
        placement: 'auto' 
       }); 
       $(te).popover('show'); 
       userids.push(userid); 
      }); 
     } 
     else { 
      $(te).popover('show'); 
     } 
    } 
}); 

$(document).on('mouseleave', '.postusername', function(e){ 
    $(this).popover('hide'); 
}); 

그러나

이 그것을 제거하지 않고 문제를 해결해야하고, 당신은 또한 한 번만 사용자 별 사용자 정보를 얻을 것이다 의미합니다 ... 에 대한 정보를 가지고 있으며, 아직하지 않은 경우에만 정보를 얻을 수 있습니다.

관련 문제