使用tiptip和jQuery的AJAX请求后tipTip工作在'第二个'悬停() [英] tipTip works on 'second' hover after ajax request using tiptip and jquery on()
问题描述
我用一句话preSS +阿贾克斯日历未来交插件(的http://word$p$pss.org/extend/plugins/word$p$pss-plugin-ajax-calendar-with-future-posts/ )+ tiptip插件 HTTP://$c$c.drewwilson.com/entry / tiptip-的jQuery插件。我已经成功地让他们一起工作,虽然tiptip只能二号悬停 - 我的意思是,当你Ajax请求tiptip后首次悬停元素不显示。我用的是日历上我主页上的一个小部件。
I'm using wordpress + ajax calendar future post plugin ( http://wordpress.org/extend/plugins/wordpress-plugin-ajax-calendar-with-future-posts/ ) + tiptip plugins http://code.drewwilson.com/entry/tiptip-jquery-plugin. I've managed to get them working together, though the tiptip only works on the 2nd hover - What I mean is when you first time hover element after ajax request tiptip doesn't show. I use the calendar as a widget on my home page.
这是我的方式激活tiptip。
This is the way I activate tiptip.
jQuery(document).ready(function( $ ) {
$("#wp-calendar").on("hover"," td a", function(){ $(this).tipTip(); });
...
});
它工作正常进行初始加载,如果我用
it works fine for the initial load if I use
$("#wp-calendar td a").tipTip();
,但是Ajax请求后消失。
, but it disappears after ajax request.
现在的问题是如何获得的tiptip以显示它应该显示的方式:对第一悬停,的mouseenter,鼠标悬停等。我已经尝试了所有这些事件。又名:我如何获得的第一块code正常工作
The question is how do I get the tiptip to show the way it supposed to show: on the 'first hover', mouseenter, mouseover etc. I've tried all of those events. AKA: How do I get the first piece of code to work properly.
我试图找到答案,这让我以我现在的阶段。这超出了我的现在技能获得通过这一点。
I've tried to find an answer, which got me to the stage I'm now. It's beyond my 'now-skill' to get pass this.
推荐答案
那么我认为,如果你做一个AJAX调用你重新创建elemenets必须重新初始化插件。我想你应该把这个调用
Well i think that if you make an AJAX call you and recreate the elemenets you must re-initialize the plugin. I think you should put this call
$("#wp-calendar td a").tipTip();
在Ajax调用成功处理程序后,新的元素已被插入。如果你不能使用ajaxComplete控制Ajax调用尝试()
in the success handler of the ajax call AFTER the new elements have been inserted. If you can't control the ajax call try using ajaxComplete()
$('body').ajaxComplete(function(e, xhr, settings){
$("#wp-calendar td a").tipTip();
});
如果你做到这一点,我想你可以拿走这一呼吁:
If you do this, i think you can take away this call:
$("#wp-calendar").on("hover"," td a", function(){ $(this).tipTip(); });
因为你已经重新应用插件。
because you already have reapplied the plugin.
这篇关于使用tiptip和jQuery的AJAX请求后tipTip工作在'第二个'悬停()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!