EasyUI Forum
April 19, 2024, 11:29:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] tooltip on datagrid + parameter = problem  (Read 10559 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: November 01, 2016, 12:22:20 PM »

Hi all,

I found my response in this post:

http://www.jeasyui.com/forum/index.php?topic=1919.msg4247#msg4247

and it works but I have an issue:

1. For each row in the table the tooltip with ajax content is created.
2. I position the mouse over the cell A, the ajax content is displayed in tooltip, no problem.
3. I position the mouse over the cell B and ajax content is displayed in tooltip, no problem.
4. I position the mouse over the cell A again, the tooltip is empty.
5. I position the mouse over the cell C, the ajax content is displayed in tooltip, no problem.
6. I position the mouse over the cell A and B again, the tooltip is empty.

Here the code:

declare tooltip in the datagrid:
Code:
onLoadSuccess:function(){
  $('.ttp').tooltip({
    content: $('<div></div>'),
    position: 'right',
    hideEvent: 'none',
    onShow: function(){
      var t = $(this);
      t.tooltip('tip').focus().unbind().bind('blur',function(){
        t.tooltip('hide');
      });
    },
    onUpdate:function(content){
      var opts = $(this).tooltip('options');
      var id_ticket = opts.param;
      content.panel({
        width: 600,
        height: 'auto',
        border: false,
        href: 'resume_ticket.php?id_ticket='+id_ticket
      });
    }
  });
}

then in every cell:
Code:
formatter: function(value,row,index){
  return '<a href=\'#\' class=\'ttp\' data-options=\'param:'+row.id_ticket+'\'>'+value+'</a>';
}

what I believe is that once the contents of a cell is requested, is not updated when the content is requested again

appreciate any help

thanks
« Last Edit: November 02, 2016, 04:35:03 PM by catpaw » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 01, 2016, 05:57:23 PM »

All your tooltip components use the same 'content'. This is why you lose the content when moving the mouse on another cell. To solve this issue, please use this code instead.
Code:
$('.ttp').tooltip({
  content: function(){return $('<div></div>')}
});
« Last Edit: November 02, 2016, 03:16:54 PM by stworthy » Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #2 on: November 02, 2016, 07:41:19 AM »

hi stworthy

I changed my code like you told me

Code:
onLoadSuccess:function(){
  $('.ttp').tooltip({
    content: function(){return '<div></div>'},
    position: 'right',
    hideEvent: 'none',
    onShow: function(){
      var t = $(this);
      t.tooltip('tip').focus().unbind().bind('blur',function(){
        t.tooltip('hide');
      });
    },
    onUpdate:function(content){
      var opts = $(this).tooltip('options');
      var id_ticket = opts.param;
      content.panel({
        width: 600,
        height: 'auto',
        border: false,
        href: 'resume_ticket.php?id_ticket='+id_ticket
      });
    }
  });
}

but I get this error:

Quote
Uncaught TypeError: content.panel is not a function

if I do an alert of content:

alert(JSON.stringify(content));

with content: function(){return '<div></div>'}, the alert is -- "<div></div>" --> get error
with content: $('<div></div>'), the alert is {"0":{},"length":1} --> remains the problem
« Last Edit: November 02, 2016, 08:41:56 AM by catpaw » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: November 02, 2016, 03:18:05 PM »

The 'content' function should be:
Code:
content: function(){return $('<div></div>')}
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #4 on: November 02, 2016, 04:34:38 PM »

hi stworthy, as always thank you for your help, it works now
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!