我使用Joomla-3为我的网站,我已经创建了一个简单的小JavaScript(ajax)文件,我通过模板配置文件附加(如模板的文档所示)。
我还在一篇文章中添加了我的html (没有TinyMCE等,所以我知道它接受我的代码)。该脚本在简单的.html或.php文件中工作得很好,但它不能与Joomla一起工作。
我的脚本有2个相关的ajax下拉菜单(静态内容)。你对可能出错的地方有什么想法吗?
提前谢谢你!
PS。你可以找到我的JavaScript here的代码。
代码如下:
$(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;
});
});
});发布于 2013-04-09 18:27:17
是否尝试过?$(Window).on(‘load’,function(){ // AWESOMENESS })
https://stackoverflow.com/questions/15892943
复制相似问题