Hey all I am trying to have my Jquery UI Auto-complete to take in a json string and have me able to only search from the first "Name" in the json and then be able to access the "image" part as well (i am inserting an image next to the name when it populates).
The json would look like this:
var availableData = [
{"Name": "bob barker", "image": "./images/bbarker.png"},
{"Name": "Jill bill", "image": "./images/jBill.png"},
{"Name": "John Doe", "image": "./images/jdoe.png"},
etc etc....
and the auto-complete script:
$( "#autocomplete" ).autocomplete({
source: availableData,
dataType: "json"
})
But i need to change the jquery-ui-1.10.4.js file in order to be able to read the json since it normally took in an array.
Any help would be great!
An example would be here but i cant seem to get that example to work with my code?
update for irvin-dominin-aka-edward
_renderItem: function( ul, item ) {
return $( "<li>" )
.append( $( "<a>" ).text( item.label ) )
.css({
"background-image":"url('https://www.zzzzzz.com/photo?" + item.image + "')",
"background-repeat":"no-repeat",
"background-position":"top left",
"background-size":"30px 30px",
"padding-left":"25px"
})
.appendTo( ul );
},
I am unable to get the "image" (using item.image) value.. I can get the "name" value just fine by doing item.label.
valueandlabelproperties.