.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
if ( ( item.parent_term_id == "16" ) ) {
.append( "<a>" + (item.child_term ? item.child_term : + "") + "</a>" )
}
.appendTo( ul );
};
This code is belong to JqueryUi Autocomplete widget. I want autocomplete text input to suggest items if their “parent_term_id” is equals to something, else suggest nothing. (It’s WordPress)
But that if statement is not working. Any idea?
The endless chaining you see in jQuery code is not always the best way to do something.
Here you’re better off using a variable:
You could combine some of those, but for the
if, you have to stop doing the chained function calls, which means using a var.