Javascript autocomplete function href

Posted by user896692 on Stack Overflow See other posts from Stack Overflow or by user896692
Published on 2011-11-25T09:08:27Z Indexed on 2011/11/25 9:50 UTC
Read the original article Hit count: 160

Filed under:
|
|
|

I´ve the following javascript-function:

   <script type="text/javascript">

    $(function() {
        var data = (<?php include("php/search_new.php"); ?>).Data.Recipes;
        var source = [];
        for (var i in data) {
            source.push({"href": "/php/get_recipe_byID.php?id=" + data[i].ID, "label": data[i].TITLE});
        }
        $("#searchrecipes").autocomplete({
            minLength: 3,
            source: source,
            select: function(event, ui) {
                window.location.href = ui.item.href;
        }
    }); 
});

   </script> 

<input id="searchrecipes" type="text" name="searchrecipes" style="margin-left: 850px; margin-top: 0px; width:170px; background: #fff url(images/search_icon.png) no-repeat 100%;"  onblur="this.style.background='#ffffff';   background: #fff url(images/search_icon.png) no-repeat 100%;" onfocus="this.style.background='#c40606';  background: url(images/search_icon.png) no-repeat 100%;"  placeholder="Suchen..."></input>
                <input type="submit" name="buttonsenden" style="display:none;" value="" width: 5px></input>

The function has already worked but suddenly it stopped working. The problem is, that the href on the dropdown-autocomplete isn´t clickable.

var data = ({"Data":{"Recipes":{"Recipe_5":{"ID":"5","TITLE":"Spaghetti Bolognese"},"Recipe_7":{"ID":"7","TITLE":"Wurstel"},"Recipe_9":{"ID":"9","TITLE":"Schnitzel"},"Recipe_10":{"ID":"10","TITLE":null},"Recipe_19":{"ID":"19","TITLE":null},"Recipe_20":{"ID":"20","TITLE":"Hundefutter"},"Recipe_26":{"ID":"26","TITLE":"Apfelstrudel"},"Recipe_37":{"ID":"37","TITLE":null},"Recipe_38":{"ID":"38","TITLE":"AENDERUNG"},"Recipe_39":{"ID":"39","TITLE":null},"Recipe_40":{"ID":"40","TITLE":"Schnitzel"},"Recipe_42":{"ID":"42","TITLE":"Release-Test"},"Recipe_43":{"ID":"43","TITLE":"Wurstel2"}}},"Message":null,"Code":200}).Data.Recipes;

All the necessary jquery scripts are available. What can be the problem?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html