工具提示.tooltipster('open')抛出错误。

时间:2018-10-04 12:37:48

标签: javascript tooltipster

我遇到Tooltipster的问题。无法弄清楚为什么“打开”不起作用,而根据文档却应该起作用?

我已经在jsfiddle上设置了它

HTML

<button id="broken" title="Broken Tooltip">Broken</button>

JS:

  $('#broken').on('click', function(e) {
    $('#broken').tooltipster('open');
  });

但是会引发错误:

Uncaught Error: Unknown method .tooltipster("open")
<...?

例如,将'open'替换为'destroy'很好。

任何人都可以弄清楚我在做什么错吗?还是提示工具本身损坏了?

2 个答案:

答案 0 :(得分:1)

工具提示中有trigger:'click'

$(document).ready(function() {
  $('#search').tooltipster({

  });

  $('#broken').tooltipster({
    trigger: 'click'
  });


});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.min.js"></script>
<button id="search" title="Tooltip Working">Search</button>

<button id="broken" title="Broken Tooltip">Broken</button>

答案 1 :(得分:1)

尝试使用trigger: 'click'示例http://jsfiddle.net/9gj8c57w/3/

$(document).ready(function() {
  $('#search').tooltipster({

  });

  $('#broken').tooltipster({
    trigger: 'click'
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" rel="stylesheet"/>



<button id="search" title="Tooltip Working">Search</button>

<button id="broken" title="Broken Tooltip">Broken</button>