简体   繁体   English

Qtip第一次单击不起作用,然后单击全部确定

[英]Qtip it does not work the first time click, next click all OK

I'm using the jQuery qtip plugin. 我正在使用jQuery qtip插件。 I want the content of the qtip to be an php code, loaded dynamically. 我希望qtip的内容是动态加载的php代码。 Here my ajax code: 这是我的ajax代码:

$(document).ready(function(){
$('.mapa').qtip({
         show: 'click',
         hide: 'click',
         content:{
                    text: function(event, api) {
                             $.ajax({
                                   url: '/google_maps/mapa.php'
                                   })
                            .then(function(content) {
                               api.elements.tooltip.html(content);
                            }, function(xhr, status, error) {
                               api.set('content.text', status + ':  ' + error);
                            });
                            return 'Loading...'; // Set some initial text

                    },
                },
        position: {
        my: 'top right',
        at: 'top center',
        },
        style: {
        classes: 'qtip-blue',
        }
    });
});

Then I select a link with the id="mapa" to load Qtip with php code the fisrt click no load php code in Qtip, the second and next click, Qtip work OK. 然后,我选择一个带有id =“ mapa”的链接,以用PHP代码加载Qtip,首先单击Qtip,然后单击两次,然后单击Qtip,这样OK即可。 If i refresh page, again no work first, second all OK. 如果我刷新页面,再次没有任何工作,其次一切都OK。 Can anyone help me? 谁能帮我? Error committing in my call on ajax? 提交我对ajax的调用时出错? Or elsewhere? 还是其他地方? Thank you very much for any help. 非常感谢您的帮助。

If you try changing api.elements.tooltip.html(content); 如果您尝试更改api.elements.tooltip.html(content); to api.set('content.text', content); api.set('content.text', content); , does it show your content on the first click? ,它在第一次点击时是否显示您的内容?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM