mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
closed #40 by removing jquery call that repetitvely bound and unbound anchors
This commit is contained in:
@@ -52,7 +52,6 @@ var ajaxify = {};
|
||||
templates.load_template(function() {
|
||||
exec_body_scripts(content);
|
||||
|
||||
ajaxify.enable();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
@@ -67,21 +66,8 @@ var ajaxify = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
ajaxify.enable = function() {
|
||||
$('a').unbind('click', ajaxify.onclick).bind('click', ajaxify.onclick);
|
||||
}
|
||||
|
||||
ajaxify.onclick = function(ev) {
|
||||
if (this.href == window.location.href + "#") return;
|
||||
var url = this.href.replace(rootUrl +'/', '');
|
||||
|
||||
if (this.target !== '') return;
|
||||
|
||||
if (!ev.ctrlKey && ev.which === 1) {
|
||||
if (ajaxify.go(url)) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('document').ready(function() {
|
||||
@@ -89,7 +75,19 @@ var ajaxify = {};
|
||||
|
||||
content = content || document.getElementById('content');
|
||||
|
||||
ajaxify.enable();
|
||||
// Enhancing all anchors to ajaxify...
|
||||
$(document.body).on('click', 'a', function(e) {
|
||||
if (this.href == window.location.href + "#") return;
|
||||
var url = this.href.replace(rootUrl +'/', '');
|
||||
|
||||
if (this.target !== '') return;
|
||||
|
||||
if (!e.ctrlKey && e.which === 1) {
|
||||
if (ajaxify.go(url)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user