jquery - 当粘性: true?时,如何通过ajax回调设置crudetop工具提示的标题

标签 jquery ajax title cluetip

我正在使用cluetip plugin which是很棒的。我正在使用 Ajax 填充插件,但我无法在任何地方(在文档或示例中)了解如何从 ajax 回调设置标题。

线索提示是否支持通过ajax更新标题?

更新说明:

因此,下面给出的建议是有效的,因为它们可以创建标题,但在这种情况下,关闭按钮不会显示在标题中。参见下图。

enter image description here

最佳答案

其实,从简单的角度来看,还是很容易的。

首先要注意的是,文档中的所有线索提示仅使用一个标记布局来显示所有提示。每次触发新的线索提示时,它只会更新其标记布局并显示它。

让我们看看example如何解决您正在尝试的问题

<小时/>

我为此使用了演示。所以标记是:

注意:我使用两个线索提示来模拟具有多个线索提示的案例

<a class="title" title="hello" href="http://plugins.learningjquery.com/cluetip/demo/ajax3.html" rel="http://plugins.learningjquery.com/cluetip/demo/ajax3.html">This example</a>

<a class="basic" href="http://plugins.learningjquery.com/cluetip/demo/ajax.html" rel="http://plugins.learningjquery.com/cluetip/demo/ajax.html">Basic</a>

让我们对样式进行一些小的更改,以便它正确对齐

.cluetip-close { float: right; margin-top: -40px; }

现在,我们的脚本,用于两个线索提示。

  var title;
  $('a.title').cluetip({
      closePosition: 'top',
      sticky: true,
      closeText: '<img src="http://plugins.learningjquery.com/cluetip/demo/cross.png" alt="close" width="16" height="16" />Close',            
      ajaxCache: false,
      ajaxSettings:  {
        success: function(data) {
            title = "Your new Title";            
            $(this).attr("title", title); //just set the title for consistency
        }
      },
      onShow : function(ct,c) {
          $(".cluetip-title").text(title); //update the title class with the title
      }
  });

  $('a.basic').cluetip(); //While definning another tip, it is NOT affected by previous one

完成

尽管fiddle可能不会显示出来。我已经测试过它并且它有效

关于jquery - 当粘性: true?时,如何通过ajax回调设置crudetop工具提示的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961336/

相关文章:

android - ActionBar 自定义标题颜色

android - 如何为自定义微调器设置默认标题?

php - 使用 PHP 和 jQuery 将 PDF 打印到页面

javascript - 监视请求结果以检测 session 超时的简单方法?

javascript - 上传电子邮件通知

java - 无法使用Tomcat 7,Java MVC设置 session 变量

javascript - Ember.js Controller 和 View 绑定(bind)(ember.js 方式...)

jquery - 如何通过 jQuery 从标题中包装一个 ELEMENT?

javascript - JQuery 使用其他元素激活悬停状态

javascript - 切换功能使所有其他 div 消失