1

Using:

.data( "autocomplete" )._renderItem = function( ul, item ) {
                var temp = item.url.substring(16, item.url.length)
                return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.value + "<br>" + item.url + "<br>" + item.description + "<br>" + "Support URL: " + item.support_url + "<br>" + "Contact: " + "<a href=" + item.contact + ">Test</a>" + "<br />" + "</a>"  )
                .appendTo( ul )

jQuery is parsing the item.url and automatically making that a href in the html. I'd like to manually control what becomes an href so that I can do something like "<a href='" + item.url + ">" + item.title "</a>"

The way jQuery handles that now is making item.url an href and adding my html href and not using the title properly.

In an older version of autocomplete I was able to do a .result(function(event, item) { location.href = item.url; }); but that doesn't seam to be supported here.

1 Answer 1

1

You can supply a callback that will be executed when an item is being selected.

$("#input").autocomplete({
    source: mySource, 
    select: function(event, ui){
        window.location = ui.item.url;
    }
});

Ref: http://docs.jquery.com/UI/Autocomplete#event-select

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.