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/", {
async:false,
dataType:'json',
type:'GET',
success:function (data) {
var labels = data.labels;
for (var i = 0; i < labels.length; i++) {
createLabelItem(labels[i])
if (options.postUpdate) {
options.postUpdate(data)
}
},
error:function (jqXHR, textStatus, errorThrown) {