Every time I loop through this foreach, a dropdown gets set with database values. When a table has a value for name
it keeps it's value when it is empty; it doesn't show anything. That's good. But every time a name is displayed, I want a FontAwesome icon in front of this.name
. Example <i class="fas fa-car">
.
How do I get this HTML tag in-between text:
and (this.name ?
?
processResults: function (data, params) {
var results = [];
jQuery.each(data, function () {
results.push({
id: this.id,
text: (this.name ? this.name + ' ' : '')
+ (this.firstname ? this.firstname + ' ' : '')
+ (this.middlename ? this.middlename + ' ' : '')
+ (this.lastname ? this.lastname + ' ' : '')
+ ' (' + this.email + ')',
});
});
return {
results: results,
pagination: {
more: false
}
};
}
I got the question to put a bit of HTML in my question so here you go :)
<div class="form-group row">
<label class="col-md-2 col-form-label" for="users">{{ trans('messages.receiver') }}</label>
<div class="col-md-10">
<select id="users" title="Search users" multiple class="form-control" name="user_ids[]"></select>
</div>
</div>