简体   繁体   English

在Joomla中自动完成

[英]Autocomplete in joomla

I'd like to add the autocomplete to a joomla componenet that I'm developing I used JQuery I follwed this exemple 我想将自动完成功能添加到正在开发的joomla componenet中,我使用的是JQuery,我已将此示例

http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/ http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/

The exemple work well but there is some problem 示例工作正常,但存在一些问题

1 - When you add JQuery with joomla you have some problems with mootlools wen I added Jquery with this code 1-当您用joomla添加JQuery时,mootlools存在一些问题,我用此代码添加了Jquery

 if(!JFactory::getApplication()->get('jquery'))
        {
             JFactory::getApplication()->set('jquery',true);
             $document = JFactory::getDocument();
             $document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery.js");
        }
        if(!JFactory::getApplication()->get('jquery.min'))
        {
             JFactory::getApplication()->set('jquery.min',true);
             $document = JFactory::getDocument();
             $document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery.min.js");
        }
        if(!JFactory::getApplication()->get('jquery-ui.min'))
        {
             JFactory::getApplication()->set('jquery-ui.min',true);
             $document = JFactory::getDocument();
             $document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery-ui.min.js");

        }

I got some Javascript error with Mootools(thank's to firebug) 我在Mootools上遇到了一些Javascript错误(感谢Firebug)

2 - Even I think some css does not work any more 2-甚至我认为某些CSS也不再起作用

Well can someone please help me to add autcomplete to joomla componene, and how to add JQuery to Joomla without having problem 好吧有人可以帮我将autcomplete添加到joomla componene中,以及如何将JQuery添加到Joomla中而不会出现问题

Actually I tried to add JQuery with onther way, edit this file \\libraries\\joomla\\document\\html\\renderer 实际上,我尝试以其他方式添加JQuery,编辑此文件\\ libraries \\ joomla \\ document \\ html \\ renderer

but I does not work I have problem with Jquery then 但是我不工作,那么我对Jquery有问题

Not sure on what the error is exactly but it sounds like a conflict. 不确定错误的确切原因,但听起来像是冲突。

First of all, you're using the correct method to ensure your scripts only get imported once, however check Firebug see see if you only have 1 of each being imported just in case. 首先,您正在使用正确的方法来确保脚本仅被导入一次,但是请检查Firebug,看看是否只有一个被导入,以防万一。 You will then need to call noConflict like so: 然后,您需要像这样调用noConflict:

$document = JFactory::getDocument();
$document->addScriptDeclaration( $noconflict );

What you could also do to import jQuery and jQuery UI only once and in noConflict mode is use the jQuery Easy Plugin: 您也可以只在一次noConflict模式下导入jQuery和jQuery UI的方法是使用jQuery Easy Plugin:

One of the features that will apply to you is: 适用于您的功能之一是:

  • places jQuery libraries after MooTools calls for perfect compatibility 在MooTools调用之后放置jQuery库以实现完美兼容性

Hope this helps 希望这可以帮助

replace above code with 用上面的代码替换

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

and in your js file start like this 并在您的js文件中像这样开始

jQuery(document).ready(function($) {
 // your code goes here
}

to get ready-made code you can use JQUERY UI in ready function 要获取现成的代码,可以在ready函数中使用JQUERY UI

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

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