简体   繁体   English

如何将Jquery或Jquery插件添加到Joomla 3

[英]How to add Jquery or Jquery plugins to Joomla 3

I have basic knowledge of HTML, CSS, Jquery and PHP. 我有HTML,CSS,Jquery和PHP的基本知识。 I would say my understanding of Joomla is very good though. 我会说我对Joomla的理解非常好。 My problem is that I have looked endlessly through search engines on how exactly to implement Jquery into Joomla 3. From my understanding Joomla 3 already comes with Jquery? 我的问题是我通过搜索引擎无休止地看看如何将Jquery实现到Joomla 3.从我的理解Joomla 3已经附带了Jquery? Does that mean I no longer have to reference it in my HTML? 这是否意味着我不再需要在我的HTML中引用它? I realize Joomla Documentation states I should call JHtml::_('jquery.framework'); 我意识到Joomla Documentation声明我应该调用JHtml::_('jquery.framework'); but where and how exactly would I call this? 但我在哪里以及如何称呼这个? I am assuming in the head of my HTML document? 我在HTML文档的头部假设? Another question is that is my understanding was that Joomla's default editor is a word processor not a HTML editor? 另一个问题是,我的理解是Joomla的默认编辑器是文字处理器而不是HTML编辑器? I realize their are other editor extensions I could download, is their one that is recommended? 我意识到他们是我可以下载的其他编辑器扩展,是他们推荐的吗?

I am looking for clear instructions on exactly how I would add my own Jquery or a plugin already available, my apologies in advance if my question sounds stupid in any way as I am very new to this and did attempt to search and experiment for an answer before coming here. 我正在寻找关于如何添加我自己的Jquery或已经可用的插件的明确说明,如果我的问题听起来很愚蠢,我会提前道歉,因为我对此非常陌生并尝试搜索和试验答案来之前来。

Using JHtml::_('jquery.framework'); 使用JHtml::_('jquery.framework'); will automatically call jQuery (in noConflict mode) and import it on the site. 将自动调用jQuery(在noConflict模式下)并在站点上导入它。 You can use this snippet anywhere in your code as it will also automatically get appended to the <head> tags 您可以在代码中的任何位置使用此代码段,因为它也会自动附加到<head>标记

You can add jQuery and your own Javascript files and also style sheets by adding the necessary commands at the top of the file where you need to use them, as in the following example: 您可以通过在需要使用它们的文件顶部添加必要的命令来添加jQuery和您自己的Javascript文件以及样式表,如下例所示:

<HTML>
<head>

<?php

defined('_JEXEC') or die;

JFactory::getDocument()->addStyleSheet(JURI::root().'/tmpl/default.css');
JHtml::script(JURI::base() . '/tmpl/jquery-ui-1.10.3.custom.js');
JHtml::_('jquery.framework'); // load jquery
JHtml::_('jquery.ui'); // load jquery ui
JHtml::script(JURI::base() . 'tmpl/sample.js');

</head>

<body>

<!-- Remainder of your page content would go here -->

</body>

?>

I have found that sometimes Joomla is sensitive to the order in which things are loaded but a little experimentation generally solves the problem. 我发现有时Joomla对事物加载的顺序很敏感,但是一些实验通常可以解决问题。

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

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