简体   繁体   English

jQuery slideToggle在joomla上不起作用,但适用于jsbin

[英]jQuery slideToggle doesn't work on joomla, but works on jsbin

So I have a website and I want to use the jQuery slideToggle to move the blocks. 所以我有一个网站,我想使用jQuery slideToggle来移动块。 The problem is that it doesn't work on my Joomla website. 问题是它在我的Joomla网站上不起作用。 However, when I copy the code to jsbin.com, it works. 但是,当我将代码复制到jsbin.com时,它可以工作。 Here's the link http://jsbin.com/EcObOwex/1/edit Here's the actual JS I'm using: 这是链接http://jsbin.com/EcObOwex/1/edit这是我正在使用的实际JS:

$('.sTurinys').hover(function(){
$('.ssTurinys',(this)).stop().slideToggle(600);
});

I don't know what additional information I can provide. 我不知道我能提供哪些其他信息。 The JS code is in splash.js, link to it works properly (checked it, there's some other script that works from the file) JS代码在splash.js中,链接到它正常工作(检查它,还有一些其他脚本可以从文件中运行)

Edit: I was informed that it was an JS error that I was getting. 编辑:我被告知这是一个JS错误,我得到了。 Here's the error Uncaught TypeError: Object [object Object] has no method 'tooltip' And here's the code. 这是错误Uncaught TypeError: Object [object Object] has no method 'tooltip'这里是代码。 Could anyone help me determine what is it? 任何人都可以帮我确定它是什么?

<script type="text/javascript">
window.addEvent('load', function() {
            new JCaption('img.caption');
        });
jQuery(document).ready(function()
            {
                jQuery('.hasTooltip').tooltip({"container": false});
            });

I didn't add it manually, it's part of the <jdoc:include type="head" /> . 我没有手动添加它,它是<jdoc:include type="head" /> Could anyone help me determine how to shake this code off? 任何人都可以帮我确定如何摆脱这个代码?

EDIT 2: Some more information: Here's my full <head> code. 编辑2:更多信息:这是我的完整<head>代码。 http://jsbin.com/aFOZEWI/2/edit AND YOU CAN ALSO FIND THE FULL SPLASH.JS in the JavaScript part of the Bin. http://jsbin.com/aFOZEWI/2/edit 你也可以在Bin的JavaScript部分找到完整的SPLASH.JS。 PS The other part of the splash.js works, my overflow element changes just as it's intended. PS splash.js的另一部分工作,我的溢出元素就像它的预期一样改变。

It might be possible that you have multiple jQuery libraries being imported which may cause conflicts. 您可能有多个jQuery库被导入,这可能会导致冲突。 In addition to that, let's import the scripts and add you code using Joomla coding standards. 除此之外,让我们导入脚本并使用Joomla编码标准添加代码。

<?php      
   JHtml::_('jquery.framework'); //This calls jQuery in noConflict mode
   $doc = JFactory::getDocument();
   $doc->addScript(JUri::root() . 'templates/vabankbroker/src/splash.js');
   $doc->addScriptDeclaration("
      $('.sTurinys').hover(function(){
          $('.ssTurinys',(this)).stop().slideToggle(600);
      });
  ");
?>

As for the Tooltip error, open the index.php of your template and if the following doesn't exist, I would recommend you add it: 至于工具提示错误,打开模板的index.php,如果以下不存在,我建议你添加它:

JHtml::_('bootstrap.framework');

Hope this helps 希望这可以帮助

I found my answer through this post: 我通过这篇文章找到了答案:
My script works in jsfiddle but not site. 我的脚本在jsfiddle中工作但不在站点上工作。 Cannot call method hover of null? 无法调用null的方法悬停? Thank you for all kinds of notices, I'll make all those fixes, but for this exact problem, I had to include the script in the end of the <body> tag, and it started working. 感谢各种通知,我会做所有这些修复,但对于这个确切的问题,我必须在<body>标记的末尾包含脚本,它开始工作。
Cheers :) 干杯:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM