tags:

views:

457

answers:

3

Hi all,

I want to pass a dynamic parameter with qTip, but it fails. my_ajax_controller.php just displays the variable type, but not 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'
});

However, a static value of q works:

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

Is there no way to pass a dynamic value to the parameter data ?

Thanks in advance !

Florent

+1  A: 

try something like this:

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

I haven't tested this, but i've done something similar. Just can't find it right now.

Patricia
This solution works nicely.
Jeremy
A: 
FrenchiInLa
This doesn't work.
Lance Fisher
+1  A: 

I had the same problem and i solved with this code. Works fine with qtip 1.0 rc3 and JQuery 1.4.2. Note that qtip has and issue with jquery>1.3. Google for related info, but it's easy to fix adding a single line on 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'
   })
});
Cibernox