brotherton-erpnext/erpnext/public/js/hub/components/search_bar.js
Prateeksha Singh c5a9972785 [refactor][major] Separate out Components
- item_card
- item_card_container
- detail_view
- search_bar
- reviews
- skeleton_state
- empty_state
- empty_state
2018-08-13 21:36:07 +05:30

21 lines
535 B
JavaScript

function make_search_bar({wrapper, on_search, placeholder = __('Search for anything')}) {
const $search = $(`
<div class="hub-search-container">
<input type="text" class="form-control" placeholder="${placeholder}">
</div>`
);
wrapper.append($search);
const $search_input = $search.find('input');
$search_input.on('keydown', frappe.utils.debounce((e) => {
if (e.which === frappe.ui.keyCode.ENTER) {
const search_value = $search_input.val();
on_search(search_value);
}
}, 300));
}
export {
make_search_bar
}