mapserver/static/js/components/SearchInput.js

39 lines
746 B
JavaScript
Raw Normal View History

const state = {
query: ""
2019-09-01 13:06:47 +03:00
};
function doSearch(){
m.route.set(`/search/${state.query}`);
}
2019-06-11 16:01:16 +03:00
2019-06-11 15:16:41 +03:00
export default {
view: function(){
function handleInput(e){
state.query = e.target.value;
2019-04-21 22:51:43 +03:00
}
function handleKeyDown(e){
if (e.keyCode == 13){
doSearch();
2019-04-21 22:51:43 +03:00
}
}
2019-04-14 20:51:31 +03:00
return m("div", { class: "input-group mb-3" }, [
2019-04-15 08:54:11 +03:00
m("input[type=text]", {
placeholder: "Search",
class: "form-control",
oninput: handleInput,
2019-04-21 22:51:43 +03:00
onkeydown: handleKeyDown,
value: state.query
2019-04-21 22:51:43 +03:00
}),
m("div", { class: "input-group-append", onclick: doSearch }, [
2019-04-21 22:51:43 +03:00
m("span", { class: "input-group-text" }, [
m("i", { class: "fa fa-search"})
])
])
2019-04-14 20:51:31 +03:00
]);
}
2019-04-15 08:54:11 +03:00
};