
very nice.
thank you!
i tested on MODxHost template, it didn’t work.
logged out to turning QuickEdit off, it worked well in IE7 but didn’t worked on opera 9.21 and firefox 2.
remove mootools JSs from modxHost to test it, firefox problem solved but opera doesn’t display result well.
ajax links work well, loading appears, new content appears but after a second content disappears.
i test your test-site in opera, works well probably it has problem with other JSs in MODxHost. (i use jQuery 1.2.4)
i only wanted to report it, your tutorial is very very good, useful, ....
we created the Persian MODx support site (and forums) at http://modxcms.ir/forums,
i will share this great tutorial with other Persian users in Persian language, if you let me!




<div id="content">
<div id="toload">
[*content*]
</div>
</div>
<script>
window.addEvent('domready', function(){
new pageLoader({loadInTo:'content',
loadFrom:'toload',
links:'ajaxlink',
onStart: $(this.options.loadInTo).replaceWith("<div id='loader'><img src='assets/images/ajax-loader.gif' /><br /><p style='font-size:20px; color:red;'>Loading content <br />please wait!</p></div>");});
new History();
});
</script> set: function(str){
var url = this.formatURL(this.url);
str = this.formatHash(str);
>>> str = str.replace("replace this with your url that will be substracted", "");
this.url = url+'#'+str;
window.location.href = this.url;
if(window.ie){
this.iframe.setProperty('src', str);
}Access to restricted URI denied" code: "1012
[Break on this error] xhr.open(type,s.url,s.async);try{if(s.da...[s.url]=modRes;if(!jsonp)success();}else28xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}elsefunction processEvent (evt)
{
evt = evt || window.event;
if (evt.which > 1 || evt.button > 1) return;
var src = evt.target || evt.srcElement;
if (src.nodeType && src.nodeType != 1) src = src.parentNode;
while (src)
{
var srcName = (src.nodeName||src.tagName||'').toLowerCase();
if (srcName == 'a' && src.className && src.className.match(/^(load|toggle)into-(.+)$/))
{
if (RegExp.$1 == 'load') return loadInto(src, RegExp.$2, evt);
if (RegExp.$1 == 'toggle') return toggleInto(src, RegExp.$2, evt);
}
src = src.parentNode;
}
};
addEvent(document, 'click', processEvent(evt), 1);
addEvent(document, 'mouseover', processEvent(evt), 1);
$rowTpl = '@CODE:<li><a onmouseover="this.class=\'loadinto-resume_rubrique\';this.rel=\'Template_resume_rubrique\';" onclick="this.class=\'loadinto-texte_rubrique\';this.rel=\'Template_texte_rubrique\';" href="[+wf.link+]" title="[+wf.pagetitle+]"> <div class="chapeau lettrine">[+wf.linktext+]</div><span></span> </a></li>';
I could change the code so that different contents are loaded by Ajax into different target containers depending on which event occurs: mouseover or click.
There’s however a problem with my the target for the template defined by the rel attribute: it’s the parent document and not the content retrieved par Ajax.
addEvent(document, 'mouseover', function(evt){
evt = evt || window.event;
if (evt.which > 1 || evt.button > 1) return;
var src = evt.target || evt.srcElement;
src.rel='Template_resume_rubrique';
src.className="loadinto-resume_rubrique";
if (src.nodeType && src.nodeType != 1) src = src.parentNode;
while (src)
{
var srcName = (src.nodeName||src.tagName||'').toLowerCase();
if (srcName == 'a' && src.className && src.className.match(/^(load|toggle)into-(.+)$/))
{
if (RegExp.$1 == 'load') return loadInto(src, RegExp.$2, evt);
if (RegExp.$1 == 'toggle') return toggleInto(src, RegExp.$2, evt);
}
src = src.parentNode;
}
}
, 1);
addEvent(document, 'click', function(evt){
evt = evt || window.event;
if (evt.which > 1 || evt.button > 1) return;
var src = evt.target || evt.srcElement;
if (src.nodeType && src.nodeType != 1) src = src.parentNode;
while (src)
{
var srcName = (src.nodeName||src.tagName||'').toLowerCase();
src.rel='Template_texte_rubrique';
src.className="loadinto-texte_rubrique";
if (srcName == 'a' && src.className && src.className.match(/^(load|toggle)into-(.+)$/))
{
if (RegExp.$1 == 'load') return loadInto(src, RegExp.$2, evt);
if (RegExp.$1 == 'toggle') return toggleInto(src, RegExp.$2, evt);
}
src = src.parentNode;
}
}
, 1);$rowTpl = '@CODE:<li><a href="[+wf.link+]" title="[+wf.pagetitle+]"> <div class="chapeau lettrine" >[+wf.linktext+]</div><span></span> </a></li>';
function loadInto(src, destId, evt) // Function modified by Heliotrope to accept REL attr - kudo
{
template = 'template=' + 'OwnTemplates_' + destId; // Changed this line
url = src.href;
src.href = (url.indexOf('?')>0)? url + '&' + template: url + '?' + template;
...
For a mysterious reason, the appearance of the clicked or mouseovered link also changes when an event occurs. 