Skip to content

Commit

Permalink
Refactor search use input tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Apr 30, 2024
1 parent d4eedb2 commit 9ebd11e
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions src/pages/universities/index_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,23 @@ class Universities::IndexPage < MainLayout
end

def render_search
# form(method: "get", class: "tool-bar", action: Index.path) do
# search_input(op.search, attrs: [:required], class: "custom-input")
# end

raw <<-'HEREDOC'
<form action="/universities" method="get">
<div class="row">
<input
id="search"
type="search"
name="q"
class="s12 m8 input-field"
value=""
placeholder="输入大学名称模糊搜索"
hx-get="/universities"
hx-target="#main"
hx-select="#main"
hx-trigger="search, keyup delay:400ms changed"
hx-push-url="true"
/>
<input type="submit" value="搜索"/>
</div>
</form>
HEREDOC
form(method: "get", class: "tool-bar", action: Index.path) do
div class: "row" do
input(
type: "search",
value: "",
name: "q",
class: "s12 m8 input-field",
placeholder: "输入大学名称模糊搜索",
"hx-get": "/universities",
"hx-target": "#main",
"hx-select": "#main",
"hx-trigger": "search, keyup delay:400ms changed",
"hx-push-url": "true",
)
submit("搜索", class: "btn")
end
end
end

def render_universities
Expand Down

0 comments on commit 9ebd11e

Please sign in to comment.