[英]Custom Javascript Won't Run in Joomla
I am using Joomla-3
for my websites and I have created a simple small JavaScript(ajax)
file which I attached through the template config file(as seen on the template's documentation). 我在网站上使用
Joomla-3
,并且创建了一个简单的小JavaScript(ajax)
文件,该文件通过模板配置文件附加(如模板文档中所示)。
I also added my html
in an article(without TinyMCE
etc so I know it accepts my code). 我也在文章中添加了
html
(没有TinyMCE
等,所以我知道它接受我的代码)。 The script works fine in a simple .html
or .php
file but it doesn't work along with Joomla
. 该脚本可以在简单的
.html
或.php
文件中正常运行,但不能与Joomla
一起使用。
My script has 2 dependent ajax
dropdown menus(static content). 我的脚本有2个相关的
ajax
下拉菜单(静态内容)。 Do you have any ideas on what could go wrong? 您对可能出什么问题有任何想法吗?
Thank you in advance! 先感谢您!
PS. PS。 You can find the code of my JavaScript here .
您可以在此处找到我的JavaScript的代码。
Here's the code: 这是代码:
$(window).load(function () {
var services = [];
services['service1'] = [{
"name": "Giannis",
"url": "giannis"
}, {
"name": "Kostas",
"url": "kostas"
}, {
"name": "Fillipos",
"url": "fillipos"
}
];
services['service2'] = [{
"name": "Maria",
"url": "maria"
}, {
"name": "Peter",
"url": "peter"
}, {
"name": "Jack",
"url": "jack"
}
];
services['service3'] = [{
"name": "Dimitris",
"url": "dimitris"
}, {
"name": "Takis",
"url": "takis"
}, {
"name": "Gianna",
"url": "gianna"
}
];
jQuery(document).ready(function () {
jQuery("#services").change(function () {
var selectedService = $(this).val();
$('#doctors').children().remove();
$('#doctors').append('<option value="Null">Click to select a Doctor</option>');
jQuery.each(services[selectedService], function (ind, val) {
$('#doctors').append('<option value="' + this.url + '">' + this.name + '</option>');
})
});
jQuery("#doctors").change(function () {
var redirServ = $('#services option:selected').val();
var thePersonObject = services[redirServ];
var goThere = $(this).val();
var fullurl = 'http://www.website.com/our-services/' + redirServ + '/item/' + goThere;
alert(fullurl);
//location.href = 'http://www.website.com/our-services/' + redirServ + '/item/' + goThere;
});
});
});
Tried this? 试过这个吗? $(window).on('load', function(){ // AWESOMENESS })
$(window).on('load',function(){// AWESOMENESS})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.