Jquery Vtip 插件处理动态创建的数据
我正在使用 Vtip 插件在悬停时在工具提示中显示标题值。除了当我尝试使用插件在动态创建的数据上显示工具栏时,一切都工作正常。我通常使用 live() 函数来解决这个问题。我怎样才能在他们的代码中实现 live() 函数???
this.vtip=function(){this.xOffset=-10;this.yOffset=10;$(".vtip").unbind().hover(function(a{this.t=this.title;this.title="";
this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("body").append('<p id="vtip"><img id="vtipArrow" />'+this.t+"</p>");
$("p#vtip #vtipArrow").attr("src","images/vtip_arrow.png");
$("p#vtip").css("top",this.top+"px").css("left",this.left+"px").fadeIn("slow")},function(){this.title=this.t;
$("p#vtip").fadeOut("slow").remove()}).mousemove(function(a){this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);
$("p#vtip").css("top",this.top+"px").css("left",this.left+"px")})};
jQuery(document).ready(function(a){vtip()});
I am using the Vtip plugin to show title values in a tooltip when hovered. Everything works fine apart from when I try and use the plugin to display toolips on dynamically created data. I normally get around this using live() function. How can I implement the live() function to their code???
this.vtip=function(){this.xOffset=-10;this.yOffset=10;$(".vtip").unbind().hover(function(a{this.t=this.title;this.title="";
this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("body").append('<p id="vtip"><img id="vtipArrow" />'+this.t+"</p>");
$("p#vtip #vtipArrow").attr("src","images/vtip_arrow.png");
$("p#vtip").css("top",this.top+"px").css("left",this.left+"px").fadeIn("slow")},function(){this.title=this.t;
$("p#vtip").fadeOut("slow").remove()}).mousemove(function(a){this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);
$("p#vtip").css("top",this.top+"px").css("left",this.left+"px")})};
jQuery(document).ready(function(a){vtip()});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将 vtip 函数重写为 jQuery 插件,使其可链接、允许自定义设置并可使用实时元素。它使用事件映射,因此它可以与 jQuery 1.4.3 及更高版本一起使用。享受。
I rewrote the vtip function as a jQuery plugin, to be chainable, to allow custom settings, and to work with live elements. Its using a mapping of events, so it will work with jQuery 1.4.3 and up. Enjoy.
未经测试,但应该可以工作(需要 jQuery 1.4.x):
编辑
好的,现在应该可以了!对此感到抱歉。
Untested, but should work (jQuery 1.4.x required):
EDIT
Ok, now should work! Sorry about that.