1

我已经使用Foundation 5 Framework为 Joomla 创建了一个基本模板,但是调用包括 Foundation 和 jQuery 以及调用 Foundation 需要是最后加载的部分。

<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/bower_components/foundation/js/foundation.min.js"></script>
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/bower_components/jquery/jquery.js"></script>
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/app.js"></script>

因此,我已将它们添加到模板中,当我加载模板时可以导航到它们,但由于某种原因,根据 firebug,基础不存在并且不会加载。

4

1 回答 1

1

If Firebug is saying that the file does not exist then you have used the incorrect path. As for the importing of jQuery, I would recommend you use the Joomla standards for this which will also import the file that comes package use noConflict() mode like so >> JHtml::_('jquery.framework');

Also try using the addScript() method for importing your other scripts, however please ensure that the paths are correct. So your full code will look like this:

<?php
    JHtml::_('jquery.framework');
    JHtml::_('script',  JUri::root() . 'templates/template_name/bower_components/foundation/js/foundation.min.js');
    JHtml::_('script',  JUri::root() . 'templates/template_name/js/app.js');
?>

Currently, your .js files are within the template folder, however are within different sub-folders, thus I would recommend sticking to 1 main folder for all javascript files.

Update:

I have just tested Foundations and it works fine for me. First of all, you need to ensure that jQuery is loaded first. Add the following code before the ending ` tag in your template index.php file:

<script src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/bower_components/jquery/jquery.js"></script>
<script src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/bower_components/foundation/js/foundation.min.js"></script>
<script> $(document).foundation(); </script>

Hope this helps

于 2014-02-02T23:37:31.033 回答