optimized widget call by bundling all queries into one for #1428; fixes active users widget crash

also fixes b3819fd076 properly
This commit is contained in:
psychobunny
2014-07-09 19:23:03 -04:00
parent 9fbd535b79
commit 5b6acbad1e
5 changed files with 19 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
"use strict";
/*global ajaxify, socket, templates*/
/*global ajaxify, templates*/
(function(ajaxify) {
ajaxify.widgets = {};
@@ -14,7 +14,7 @@
});
};
ajaxify.widgets.render = function(tpl_url, callback) {
ajaxify.widgets.render = function(template, url, callback) {
var widgetLocations = ['sidebar', 'footer', 'header'], numLocations;
$('#content [widget-area]').each(function() {
@@ -29,11 +29,16 @@
if (!numLocations) {
ajaxify.widgets.reposition();
}
function renderWidgets(location) {
var area = $('#content [widget-area="' + location + '"]');
var area = $('#content [widget-area="' + location + '"]'),
areaData = {
location: location,
template: template + '.tpl',
url: url
};
$.get(RELATIVE_PATH + '/api/widgets/render/' + tpl_url + '/' + location, function(renderedWidgets) {
$.get(RELATIVE_PATH + '/api/widgets/render', areaData, function(renderedWidgets) {
var html = '';
for (var i=0; i<renderedWidgets.length; ++i) {