Reputation: 161
I have an auto suggest function on a website, where it gets the categories from the database.
It works perfect on desktop computers and laptops, but when I open the page on my iphone for example, it suggest the categories, but I can't click on it to autofill the input box?
My jQuery code is
<script type="text/javascript">
$(function() {
$(".search").keyup(function() {
var searchid = $(this).val();
var dataString = 'search=' + searchid;
if (searchid != '') {
$.ajax({
type: "POST",
url: "search/search.php",
data: dataString,
cache: false,
success: function(html) {
$("#result").html(html).show();
}
});
}
return false;
});
jQuery("#result").live("click", function(e) {
var $clicked = $(e.target);
var $name = $clicked.find('.name').html();
var decoded = $("<div/>").html($name).text();
$('#searchid').val(decoded);
});
jQuery(document).live("click", function(e) {
var $clicked = $(e.target);
if (!$clicked.hasClass("search")) {
jQuery("#result").fadeOut();
}
});
$('#searchid').click(function() {
jQuery("#result").fadeIn();
});
});
</script>
And my HTML
<input type="text" class="search" id="searchid" name="tekst placeholder="What are you looking for?">
<div id="result">
</div>
I just can't see where the problem is, as mentioned the auto suggest works perfect, but it's when I want to click on the suggested word, nothing happens.
You can see the site here: http://goo.gl/YMfsn9
Hope you guys can help me.
Upvotes: 1
Views: 42
Reputation: 161
Sorry.. A friend of mine just dropped by and the answer is to make the div "pointable" with CSS
.search
{
cursor: pointer;
}
So fortunately the problem wasn't that big :-)
Upvotes: 1