I have this block :
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
And I want to put a ternary in the append statement so that its either just a label or a label with an address
item.address != '' ? item.address : ''
or a little messier but more specific..
if ( item.address != '' )
"<span class='customer_search_addr'>" + item.address + "</span>"
else
"<a>" + item.label + "</a>"
Can I make a chainable proc here since I can’t ( I don’t think I can ) add this ternary directly within an append statement.
Yes, you can add a ternary into the
appendcall:Hovewer, it’s quite messy, so i would do it like this: