js refactor

This commit is contained in:
Ezequiel Bergamaschi
2014-01-28 00:28:42 -03:00
committed by Ezequiel Bergamaschi
parent c7b193f43f
commit acb3782561
4 changed files with 193 additions and 194 deletions

View File

@@ -0,0 +1,24 @@
function createLabelItem(data) {
$("#foldersContainer").find("ul").append(
$("<li data-filter=\"" + data.title + "\">").append(
"<a href=\"#\"> <i class=\"icon-tag\"></i>" + data.title + "</a>"
)
)
}
function fetchLabels() {
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])
}
},
error:function (jqXHR, textStatus, errorThrown) {
$('#messagesPanel div').text(errorThrown).parent().show();
}
});
}