Dynamic settings for dynamic content using qTip

I want to pass a dynamic parameter using qTip, but it fails. my_ajax_controller.php just displays the type of the variable, 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, the static q value works:

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

Can't pass dynamic value to parameter data?

Thanks in advance!

Florent

+4
source share
3 answers

It should work, but just try to see what you are passing as an identifier, or pass the data as a collection, for example:

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

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 did not test this, but I did something similar. I just can’t find it right now.

+8
source

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 issues with jquery> 1.3. Google for related information, but easy to fix adding one 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' }) }); 
+3
source

Source: https://habr.com/ru/post/1301847/


All Articles