def custom_proc(request):
return {'menu': MenuItems.objects.all() }
TEMPLATES = [
{
'BACKEND': ...,
'DIRS': ...,
'OPTIONS': {
'context_processors': [
...,
'path.to.context_processors.custom_proc',
],
},
},
]
def menu(request):
return {'menu': MenuItems.objects.all()}
TEMPLATES = [
{
...
'OPTIONS': {
'context_processors': [
...
'mysite.context_processors.menu',
],
...
}
}
]
function debouncer(func, timeout) {
var timeout = timeout || 200;
var timeoutID;
return function () {
var self = this;
clearTimeout(timeoutID);
timeoutID = setTimeout(function() {
func.apply(self, Array.prototype.slice.call(arguments));
}, timeout);
}
}
var text = document.getElementById('text');
window.addEventListener("resize", debouncer(function(e) {
text.innerHTML += 'был изменён размер окна<br/>';
console.log('test');
}));