Hi There,
A bit stuck on using a callback on initSelection where I need to retrieve a single value back from an ajax call.
I added this patch here.
https://github.com/alanho/select2/commit/af1c39807611538db65886a227e9bf7227f4adbaAll seems OK and I get a valid JSON response (below) however the <span> tag is empty.
{"results":[{"id":"4255","text":"Party Tour"}]}
I was working off the sample in the above url for a result.
My code sample is below. Any help would be appreciated.
$('#activitycats').select2({
        placeholder: 'Search for an activity',
        ajax: {
            url: "/ajax/categoriesactivities.php",
            dataType: 'json',
            quietMillis: 100,
            data: function (term, page) {
                return {
                    term: term, //search term
                    page_limit: 10 // page size
                };
            },
            results: function (data, page) {
                return { results: data.results };
            }
        },
        initSelection: function(element, callback) {
            return $.getJSON("/ajax/categoriesactivities.php?id=" + (element.val()), null, function(data) {
                if ($.isFunction(callback)) {
                    return data;
                }
            });
        }
    });