Skip to content

Instantly share code, notes, and snippets.

@kaareal
Created September 29, 2010 15:13
Show Gist options
  • Save kaareal/602915 to your computer and use it in GitHub Desktop.
Save kaareal/602915 to your computer and use it in GitHub Desktop.
<form id="searchBox" action="/search" method="get" >
<input placeholder="Search spots" id="q" name="q" type="search" autofocus >
</form>
<h3>Search Results for </h3>
<ul id="searchResults">
<% if(@is_search_empty) %>
<% else %>
<% @search_result['data'].each do |result| %>
<li class='listitem spot'>
<h2 class='title'><%= h(result['poi']['name']) %></h2>
<p class='text'>
<%= h(result['poi']['tag_list']) %>
</p>
</li>
<% end %>
<% end %>
</ul>
<script type="text/sjs">
(function() {
var replace = require("common").supplant;
$('#searchBox').submit(function(){
return false;
})
while(true) {
waitfor {
$('#q').$keyup();
hold(1000);
} or {
$('#q').$submit();
}
var result = http.get('/api/poi/search?q=' + $('#q').val());
continue; //look here i have this because there is a bug somewhere below. if i dont have this it the while true only triggers once
//multiline support be works with sjs by the way
var poi, html = [], tmpl;
alert(result);
while(result.data.lenth) {
poi = result.data.shift().poi;
tmpl = replace("<li class='listitem spot'>
<h2 class='title'>{name}</h2>
<p class='text'>{tag_list}</p>
</li>", poi);
html.push(tmpl);
}
//$('#searchResults').html(html.join(''));
}
}())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment