8

i want to display the data from ajax request to tooltip, it's open in modal window right now, but I want to open it into the tooltip, how can I do that, I tried a lot but didn't get success, I stucked at here, please help me to show data through tooltip.

this is my view code

  echo $this->Manager->link('Groups',array('action'=> 'test_contact_group', $records['Contact']['contact_id']),array('class'=>'ajax_links'));

the html of this link is

   <a class="ajax_links" help="a" href="/contacts/test_contact_group/78">Groups</a>

and jquery is there

     <script>
$(".ajax_links").hover(function(e) {

    e.preventDefault(); 
    var link = $(this).attr('href');

    $.ajax({ 
        type: "POST",   
        url: link,
        cache: false
    }).done(function( html ) { 

        jQuery('#myModal').modal('show');
        jQuery('.modal-body').html("Groups" + html);

    });
});


</script>

it is diplay in modal window, but I want to open it in tooltip, how can I do that, please help me. thanks a ton in advance, I really stucked here.

Freelancer
  • 9,008
  • 7
  • 42
  • 81
user2046638
  • 366
  • 3
  • 17

3 Answers3

1

Hope this will help you..

$(".ajax_links").hover(function(e) {

    e.preventDefault(); 
    var link = $(this).attr('href');

    $.ajax({ 
        type: "GET",   
        url: link,
        success : function (data){
        $('#elementId').attr('title',data);
        } 

    });
});
tmaximini
  • 8,403
  • 6
  • 47
  • 69
Anand G
  • 3,130
  • 1
  • 22
  • 28
  • basically I want to display the data which is in view file not in attribute, the data is came from another function. – user2046638 Mar 08 '13 at 13:06
0

If the issue is only with jquery syntax, you can try this:

   $(this).attr("title", html);
Anusha
  • 419
  • 1
  • 4
  • 7
0

Instead of modal window. you just have a container for div with id tooltip. like this. then append the results. some thing like this : demo tooltip. and CSS taken from this answer Pure CSS Tooltip

$('#toolTip').show();

Working demo : DEMO for Tooltip

or you can append to title attribute.

 $('#elementId').attr('title',data);
Community
  • 1
  • 1
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
  • not work in my scenario the date is in another view which come from another function, data view file is other and link file is different – user2046638 Mar 08 '13 at 13:08