qTip动态内容的动态参数

我想用qTip传递一个动态参数,但它失败了。 my_ajax_controller.php只显示变量类型,但不显示q。

$('a.menu_help').qtip({ content: { url:'my_ajax_controller.php', data: 'type=help_menu&q='+$(this).attr('id'), method: 'get' }, show: 'mouseover', hide: 'mouseout' }); 

但是,q的静态值有效:

 $('a.menu_help').qtip({ content: { url:'my_ajax_controller.php', data: 'type=help_menu&q=toto', method: 'get' }, show: 'mouseover', hide: 'mouseout' }); 

有没有办法将动态值传递给参数数据?

提前致谢 !

弗洛朗

它应该可以工作,但只是尝试查看您作为ID传递的内容,或者将数据作为集合传递,如:

数据:{'type':'help_menu','q':id}

要么

   
  $( 'a.menu_help')。qtip({
     var id = $(this).attr('id');
    警报(ID);
    内容:{
      url: 'my_ajax_controller.php',
      数据:'type = help_menu&q ='+ id,
      方法:'得到'
     },
     show:'mouseover',
    隐藏:'mouseout'
 });

尝试这样的事情:

 $('a.menu_help').each(function(){ $currentLink = $(this); $currentLink.qtip({ content: { url:'my_ajax_controller.php', data: 'type=help_menu&q='+$currentLink.attr('id'), method: 'get' }, show: 'mouseover', hide: 'mouseout' }); 

我没有测试过这个,但我做了类似的事情。 就是现在找不到它。

我有同样的问题,我用这个代码解决了。 适用于qtip 1.0 rc3和JQuery 1.4.2。 请注意,qtip具有jquery> 1.3的问题。 谷歌提供相关信息,但很容易修复在jquery.qtip.js上添加一行

 $('.username_link').each(function(){ $(this).click(function(){ return false });//JS enabled => link default behavior disabled. Gaceful degradation $(this).qtip({ content: { url: '/users/links', data: { id: $(this).attr('data-id') }, method: 'post' }, show: 'click', hide: 'mouseout' }) });