').text(error).html() + '';
}
$rows.html(message);
}
function loadRows() {
$rows.text('در حال بارگذاری...');
request('bmm_branch_rows', {})
.done(function(res) {
if (res && res.success && res.data && typeof res.data.html !== 'undefined') {
$rows.html(res.data.html);
} else {
$rows.text('پاسخ سرور نامعتبر است: ' + JSON.stringify(res));
}
})
.fail(showError);
}
$('#bmm-search-btn').on('click', function() {
var term = $('#bmm-search').val().trim();
if (term.length < 2) {
$('#bmm-search-results').text('حداقل دو حرف وارد کنید.');
return;
}
$('#bmm-search-results').text('در حال جستجو...');
request('bmm_search_products', { term: term })
.done(function(res) {
if (!res || !res.success || !res.data || !res.data.items) {
$('#bmm-search-results').text('خطا در جستجوی محصولات.');
return;
}
var $list = $('
');
res.data.items.forEach(function(item) {
var $line = $('
').css('padding', '6px 0');
$('').text(item.title + ' (#' + item.id + ') ').appendTo($line);
$('