I am using the jquery select 2 plugin. http://ivaynberg.github.io/select2/#ajax
I have the search working, and I am able to pull in the results and select things fine. But when I reload the page I want the previous selection populated. I have the id and what I want to display, but it seems the way to do it is using an initSelection call.
This seems a bit overkill, as I already have the text I want to show....
$(".user-search").select2({
minimumInputLength: 2,
ajax: {
url: "/users/search",
dataType: 'json',
data: function (term, page) {
return { keyword: term };
},
results: function (data, page) {
return { results: data };
}
}
});
<input name="user_id" class="user-search" type="text" style="width:100%" value="{{ $user->id }}" />
Is there some way I can do $user->name? maybe set it on the input as a data-display....