Author Topic: Tooltipster in render function  (Read 5951 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Tooltipster in render function
« on: February 25, 2017, 06:37:29 pm »
Trying to use Tooltipster (http://iamceege.github.io/tooltipster/) in render function. The class is added to my img but it has no effect it seems.
Gives no error message and outside grid it works fine.

Any idea how to solve?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Tooltipster in render function
« Reply #1 on: February 27, 2017, 10:30:18 pm »
I have no idea about Tooltipster. If you could share a jsfiddle, then I might be able to look into it.

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Tooltipster in render function
« Reply #2 on: March 06, 2017, 07:46:17 pm »
Great, thanks. Put a span outside grid to show effect when it works.

https://jsfiddle.net/tjgxwLda/

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Tooltipster in render function
« Reply #3 on: March 06, 2017, 08:18:44 pm »
Ok, I see that. It's because tooltipster does one time DOM binding and doesn't observe for any changes in DOM after initial binding.

Since grid cells are composed dynamically, tooltipster could be initialized in the refresh event.

https://jsfiddle.net/tjgxwLda/1/

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Tooltipster in render function
« Reply #4 on: March 06, 2017, 08:24:59 pm »
Perfect! Thanks for quick help.

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Tooltipster in render function
« Reply #5 on: January 08, 2018, 03:24:52 pm »
Tried in toolbar like:

Code: [Select]
type: '<span class="tooltip" data-tooltip-content="#tooltip_content">This span has a tooltip with HTML when you hover over it!</span><div class="tooltip_templates">
<span id="tooltip_content"><strong>This is the content of my tooltip!</strong></span></div>',

Doesn't seem to work but get no error message, works fine outside grid...
« Last Edit: January 08, 2018, 03:28:01 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Tooltipster in render function
« Reply #6 on: January 08, 2018, 09:35:39 pm »
works fine: https://jsfiddle.net/tjgxwLda/3/

Isn't your span supposed to have title attribute?

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Tooltipster in render function
« Reply #7 on: January 09, 2018, 04:39:28 pm »
Solved, works fine in 5.0.1.
Thanks.

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Tooltipster in render function
« Reply #8 on: February 09, 2018, 03:38:57 pm »
I currently initialize tooltipster in the refresh event:

Code: [Select]
refresh: function(){
              $('.tooltip').tooltipster({
  ...
              });}

Problem is that I get in console (since v5):

"Tooltipster: one or more tooltips are already attached to the element below. Ignoring.
tooltipster.bundle.min.js:1 <span class=​"...">​…​</span>​
"

How should I initialize it instead?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Tooltipster in render function
« Reply #9 on: February 09, 2018, 04:19:27 pm »
Exclude ".tooltipstered" while initializing

Code: [Select]
$('.tooltip:not(".tooltipstered")').tooltipster({
});

https://jsfiddle.net/tjgxwLda/4/

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Tooltipster in render function
« Reply #10 on: February 12, 2018, 09:00:57 am »
Yet another way ( seems better ) to add Tooltipster to whole cell without need to add span.

Code: [Select]
        render: function(ui) {
          return {
            attr: "title='" + ui.cellData + "'",
            cls: "tooltip"
          }
        }

https://jsfiddle.net/tjgxwLda/5/
« Last Edit: February 12, 2018, 09:02:45 am by paramquery »