brand-render.js
895 Bytes
var $ = require('yoho-jquery'),
dbClass = 'data-bind';
module.exports = function(callback) {
$.ajax({
type: 'POST',
url: '/brands/searchAsync',
success: function(data) {
render(data.data);
callback && callback(data);
}
});
};
function render(data) {
console.log(data)
if (data.history && data.history.list && data.history.list.length) {
var hisEl = $('.history>li').remove();
$.each(data.history.list, function(i, his) {
var itemEl = hisEl.clone();
itemEl.find('a')
.attr('href', his.url)
.attr('brandName', his.name)
.attr('collectTime', his.searchTime)
.text(his.name);
$('.history').append(itemEl);
})
$('.net-history').removeClass(dbClass);
} else {
$('.net-history').remove();
}
}