大佬教程收集整理的这篇文章主要介绍了twitter-bootstrap – 更新data-content属性时,Twitter bootstrap js popover内容不会更新,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<ul> <li class="player_name_li" rel="popover" data-placement="right" data-html="true" data-title="Dude" data-trigger="hover" data-content="<div class='custom_content'>Heres some content</div>" data-original-title="" title=""><span class="player_name">Dude</span> </li> </ul>
然后我的脚本
$(document).ready(function(){ $('.player_name_li').popover({ template: '<div class="popover" style="width:250px;"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'}); seTinterval(function(){update_scores();},6000); function update_scores() { $.ajax({ url: host_name,type: 'POST',//async: false,data: {player_array: my_data_is_generated_from_pagE)} }).done(function(results){ var obj = $.parseJSON(results); //this reloads the stupid popover data $.each(obj.fancy_return,function(index,value){ $('.player_info_link').each(function(){ var huh = $(this).closest('li'); huh.attr('data-content',value.new_tablE); }); )}; }
现在就像我说的那样全部像我期望的那样工作,并更新每个popover li的数据内容,我通过检查dom验证了,但是当我将鼠标悬停在li上时,它仍然显示数据内容的旧内容.我查看了一些帖子并尝试在我的popover instanciation中设置内容:function(){return $(this).data(‘content’);}但是这不起作用.我也试过破坏和重新创建每个元素,但是由于它在一个区间函数中并且自动触发,它会关闭一个打开的弹出窗口,如果你有一个打开它会使它看起来像马车.有任何想法吗?
如果你定义
$('.player_name_li') .popover({ template: '<div class="popover" style="width:250px;"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>',content: function (){return $(this).data('content')} })
然后你需要使用
huh.data('content',value.new_tablE);
如果你这样做,插件将在幕后重新初始化.
以上是大佬教程为你收集整理的twitter-bootstrap – 更新data-content属性时,Twitter bootstrap js popover内容不会更新全部内容,希望文章能够帮你解决twitter-bootstrap – 更新data-content属性时,Twitter bootstrap js popover内容不会更新所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。