【问题标题】:Adding custom jquery plugin of twitter search api to Drupal将 twitter 搜索 api 的自定义 jquery 插件添加到 Drupal
【发布时间】:2012-05-17 07:37:27
【问题描述】:

我正在尝试在 Drupal 中实现这个 jquery 插件。 http://tympanus.net/codrops/2010/07/20/latest-tweets-tooltip/

我将以下 js 添加到我的 theme.info 和所需的 css 中。

scripts[] = js/jquery.twitter.search.js
scripts[] = js/jquery.twitterpopup.js

我用以下方式调用了插件

(function($) {
$('.article').find('.twitter_search').twitterpopup();
}(jQuery));

我不确定插件无法正常工作是怎么回事。我希望有人能指导我完成这个。

HTML

<div class="article">
    <span class="twitter_search">experiment</span>
</div>

【问题讨论】:

  • 您的页面中是否有article 类的元素?里面有.twitter_search 元素吗?
  • 或者换句话说:你能告诉我们你的html吗?
  • html 添加,顺便说一下我用的是drupal 7。

标签: jquery drupal drupal-7


【解决方案1】:

你从哪里调用插件?即你的函数在哪个文件中

你确定你的 JS 真的在运行吗?尝试只发出警报或控制台日志以检查是否发生了任何事情,或使用 Firebug 或 Chrome 开发工具添加断点。

使用 Drupal 检查的一件事是,自从将脚本添加到 theme.info 文件后,您已经刷新了主题注册表。

清除所有缓存,或访问主题设置页面。

【讨论】:

  • 为缓存清除提示投票。通常可以解决我的大部分奇怪问题。
  • 我将函数放在一个名为 jtweet.js 的文件中,并将它也添加到了 theme.info 中。清除了我的缓存和所有这些。我编写了另外三个自定义 jquery 脚本,但它们运行良好。我是否错误地调用了该函数?
【解决方案2】:

试试

(function($) { $('.article').find('.twitter_search').twitterpopup(); })(jQuery);

}(jQuery)) 中的语法错误必须是 })(jQuery)

【讨论】:

  • 所以如果你的函数只是说alert('hello world'); 会发生警报吗?另外,如果您使用萤火虫等,您的脚本是否在页面上?控制台是否显示任何错误?
猜你喜欢
  • 2011-06-16
  • 1970-01-01
  • 1970-01-01
  • 2016-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多