admin管理员组

文章数量:1025251

I have an angular-ui select2 ponent on my page. It works fine when the user types something in (it uses ajax to load in the data).

But the initSelection function never gets called. Here's the configuration object I pass into the select2

{
    multiple: true,
    minimumInputLength: 1,
    tokenSeparators: [",", " "],
    createSearchChoice: function (term) {
        return term;
    },
    width: 'resolve',
    ajax: {
        url: '...',
        method: 'GET',
        quietMillis: 100,
        data: function (term, page) {
            ...
        },
        results: function (data, page) {
            ...
        }
    },
    initSelection: function (element, callback) {
        console.log('initSelection');
        return $.ajax({
            url: "...",
            type: "GET",
            data: {
                ...
            },
        }).done(function(data) {
            console.log(data);
            return callback(data);
        });
    }
};

"initSelection" never gets logged to the console. Why isn't initSelection getting called?

I have an angular-ui select2 ponent on my page. It works fine when the user types something in (it uses ajax to load in the data).

But the initSelection function never gets called. Here's the configuration object I pass into the select2

{
    multiple: true,
    minimumInputLength: 1,
    tokenSeparators: [",", " "],
    createSearchChoice: function (term) {
        return term;
    },
    width: 'resolve',
    ajax: {
        url: '...',
        method: 'GET',
        quietMillis: 100,
        data: function (term, page) {
            ...
        },
        results: function (data, page) {
            ...
        }
    },
    initSelection: function (element, callback) {
        console.log('initSelection');
        return $.ajax({
            url: "...",
            type: "GET",
            data: {
                ...
            },
        }).done(function(data) {
            console.log(data);
            return callback(data);
        });
    }
};

"initSelection" never gets logged to the console. Why isn't initSelection getting called?

Share Improve this question asked Apr 17, 2013 at 1:57 markmark 5,0708 gold badges38 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

initSelection is only called when there is initial input to be processed (see blue box just above here - the closest place to link to, I'm afraid). I suspect this may be your problem from the way the question is worded.

I'm able to do selected value as Edit time using InItSelection in Angular Js.

$scope.partInitSelection = function (element, callback) {
        var resultArray = [];
        resultArray.push({ id: "1", text: "hi" });
        $scope.HospitalizationView.HospitalName = resultArray[0];
        callback(resultArray[0]);
    };

I have an angular-ui select2 ponent on my page. It works fine when the user types something in (it uses ajax to load in the data).

But the initSelection function never gets called. Here's the configuration object I pass into the select2

{
    multiple: true,
    minimumInputLength: 1,
    tokenSeparators: [",", " "],
    createSearchChoice: function (term) {
        return term;
    },
    width: 'resolve',
    ajax: {
        url: '...',
        method: 'GET',
        quietMillis: 100,
        data: function (term, page) {
            ...
        },
        results: function (data, page) {
            ...
        }
    },
    initSelection: function (element, callback) {
        console.log('initSelection');
        return $.ajax({
            url: "...",
            type: "GET",
            data: {
                ...
            },
        }).done(function(data) {
            console.log(data);
            return callback(data);
        });
    }
};

"initSelection" never gets logged to the console. Why isn't initSelection getting called?

I have an angular-ui select2 ponent on my page. It works fine when the user types something in (it uses ajax to load in the data).

But the initSelection function never gets called. Here's the configuration object I pass into the select2

{
    multiple: true,
    minimumInputLength: 1,
    tokenSeparators: [",", " "],
    createSearchChoice: function (term) {
        return term;
    },
    width: 'resolve',
    ajax: {
        url: '...',
        method: 'GET',
        quietMillis: 100,
        data: function (term, page) {
            ...
        },
        results: function (data, page) {
            ...
        }
    },
    initSelection: function (element, callback) {
        console.log('initSelection');
        return $.ajax({
            url: "...",
            type: "GET",
            data: {
                ...
            },
        }).done(function(data) {
            console.log(data);
            return callback(data);
        });
    }
};

"initSelection" never gets logged to the console. Why isn't initSelection getting called?

Share Improve this question asked Apr 17, 2013 at 1:57 markmark 5,0708 gold badges38 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

initSelection is only called when there is initial input to be processed (see blue box just above here - the closest place to link to, I'm afraid). I suspect this may be your problem from the way the question is worded.

I'm able to do selected value as Edit time using InItSelection in Angular Js.

$scope.partInitSelection = function (element, callback) {
        var resultArray = [];
        resultArray.push({ id: "1", text: "hi" });
        $scope.HospitalizationView.HospitalName = resultArray[0];
        callback(resultArray[0]);
    };

本文标签: javascriptangularui select2 initSelection not getting calledStack Overflow