fetchLabels with postUpdate callback

This commit is contained in:
Ezequiel Bergamaschi 2014-01-28 02:58:39 -03:00 committed by Ezequiel Bergamaschi
parent 2ec941e1a0
commit f048d0adb7
2 changed files with 11 additions and 5 deletions

View File

@ -163,5 +163,12 @@ $(function () {
} }
); );
$(document).ready(fetchLabels()) $(document).ready(fetchLabels({
postUpdate: function(data) {
var labels = data.labels;
for (var i = 0; i < labels.length; i++) {
createLabelItem(labels[i])
}
}
}))
}); });

View File

@ -13,15 +13,14 @@ function createLabelItem(data) {
} }
function fetchLabels() { function fetchLabels(options) {
jQuery.ajax("c/restful/labels/", { jQuery.ajax("c/restful/labels/", {
async:false, async:false,
dataType:'json', dataType:'json',
type:'GET', type:'GET',
success:function (data) { success:function (data) {
var labels = data.labels; if (options.postUpdate) {
for (var i = 0; i < labels.length; i++) { options.postUpdate(data)
createLabelItem(labels[i])
} }
}, },
error:function (jqXHR, textStatus, errorThrown) { error:function (jqXHR, textStatus, errorThrown) {