fbiville
fbiville

Reputation: 8970

Dynamic parameters for dynamic contents with qTip

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

Upvotes: 4

Views: 5917

Answers (3)

Cibernox
Cibernox

Reputation: 77

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

Upvotes: 3

Patricia
Patricia

Reputation: 7802

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.

Upvotes: 8

Frenchi In LA
Frenchi In LA

Reputation: 3169

It should work, but just try to see what you pass as ID, or pass data as collection something like:

data : {'type':'help_menu', 'q':id}

Or

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

Upvotes: -7

Related Questions