我正在尝试在点击Joomla菜单项后在后台产生浏览器刷新。
我的问题是,我已经使用ajax来处理页面上的内容组件和其他元素,以便在一个位置刷新,但我需要以这种方式更新这些内容:-用户单击菜单项,然后加载新背景和新内容
当我点击F5 /刷新页面时,背景通常会改变,这是对active menuItemID的响应;只是为了注意到,ajax基于menuItemID改变网址,但他没有改变背景,这需要从css中拉出。
我通过这种方式使用基于菜单项ID的简单css背景状态:
html部件
<body id="background<?php echo JRequest::getInt( 'Itemid' ); ?>">css (101、102、103...114是菜单项ID`s)
#background101{ background:transparent url(../images/1.jpg) no-repeat 100% 100%; }
#background102 { background:transparent url(../images/2.jpg) no-repeat 100% 100%;}
#background103 { background:transparent url(../images/3.jpg) no-repeat 100% 100%; }Joomla中安装的插件是FullAjax plugin
我读过关于配置的手册,但没有解释如何基于menuItemID刷新页面/站点背景
JavaScript代码,FullAjax的参数
FLAX.Filter.add({url:'/', id:fullAjaxId});
FLAX.Filter.add({query:['task=weblink','task=profile','task=user.login','task=user.logout','task=article.edit'], type:'nowrap'});
FLAX.Filter.on('beforewrap', function(o) {
var id = o.el.getAttribute('id'), regExt = /.+\.(jpg|jpeg|gif|png|mp3|mp4|ogg|ogv|webm|pdf|txt|odf|ods)$/i;
if(id == ('login-form') || id == ('form-login') || (o.el.href && (regExt.test(o.el.href) || o.el.href.indexOf('#') != -1))){return false;}
});
FLAX.directLink();FLAX.Default.sprt_url = '!';
FLAX.linkEqual['!ax!'+fullAjaxId+'!'] = 'ajx';FLAX.linkEqual['[~q~]'] = '?';
/* fix for mootools 'domready', uncomment if need */
/* FLAX.Html.onall('load', function(o){window.fireEvent('domready');}); */ 有人能帮帮忙吗?
发布于 2013-02-28 18:38:27
它不能工作,因为<body>不会改变,你需要在每次ajax调用后编写一些代码来改变它。
如果您启用了options Check the active menu item,则可以执行下一步操作:
FLAX.Html.onall('load', function(){
if(fullAjaxMItems.length){
//set id using MooTools
document.id(document.body).set('id', 'background' + fullAjaxMItems[0]);
}
});如果此选项未启用,则只需在模板<head>中添加将保持当前菜单项id的变量,如:
<script>
var currentItemId = <?php echo JRequest::getInt( 'Itemid' ); ?>;
</script>然后在插件配置中:
FLAX.Html.onall('load', function(){
if(window.currentItemId){
//set id using MooTools
document.id(document.body).set('id', 'background' + currentItemId);
}
});https://stackoverflow.com/questions/15131175
复制相似问题