mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
committed fix to ajaxify that caused any newly appended anchors to not be
ajaxified, also tweaked ajaxify so that it only unbinds its own events instead of clobbering any other events attached to anchors (#futureproof)
This commit is contained in:
@@ -19,7 +19,7 @@ var ajaxify = {};
|
|||||||
content.innerHTML = templates[tpl_url];
|
content.innerHTML = templates[tpl_url];
|
||||||
exec_body_scripts(content);
|
exec_body_scripts(content);
|
||||||
|
|
||||||
|
ajaxify.enableAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -28,22 +28,25 @@ var ajaxify = {};
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('document').ready(function() {
|
ajaxify.enableAll = function() {
|
||||||
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
$('a').unbind('click', ajaxify.enable).bind('click', ajaxify.enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
ajaxify.enable = function(ev) {
|
||||||
content = content || document.getElementById('content');
|
|
||||||
|
|
||||||
$('a').unbind('click').bind('click', function(ev) {
|
|
||||||
var url = this.href.replace(rootUrl +'/', '');
|
var url = this.href.replace(rootUrl +'/', '');
|
||||||
|
|
||||||
if (ajaxify.go(url)) {
|
if (ajaxify.go(url)) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('document').ready(function() {
|
||||||
|
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
||||||
|
|
||||||
});
|
content = content || document.getElementById('content');
|
||||||
|
|
||||||
|
ajaxify.enableAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
function exec_body_scripts(body_el) {
|
function exec_body_scripts(body_el) {
|
||||||
@@ -54,8 +57,7 @@ var ajaxify = {};
|
|||||||
// Argument body_el is an element in the dom.
|
// Argument body_el is an element in the dom.
|
||||||
|
|
||||||
function nodeName(elem, name) {
|
function nodeName(elem, name) {
|
||||||
return elem.nodeName && elem.nodeName.toUpperCase() ===
|
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||||
name.toUpperCase();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function evalScript(elem) {
|
function evalScript(elem) {
|
||||||
|
|||||||
Reference in New Issue
Block a user