4

我想用 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'
});

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

提前致谢 !

弗洛朗

4

3 回答 3

8

尝试这样的事情:

$('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'
});

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

于 2010-02-19T16:36:22.867 回答
3

我有同样的问题,我用这段代码解决了。适用于 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'
   })
});
于 2010-08-11T19:04:43.507 回答
-7

它应该可以工作,但只是尝试查看您作为 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,
      方法:'得到'
    },
    显示:'鼠标悬停',
    隐藏:'mouseout'
});
于 2010-02-19T16:38:51.233 回答