New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same typeahead for two different selector #68

Closed
marccollin opened this Issue Aug 21, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@marccollin

marccollin commented Aug 21, 2015

Hi

i would like to avoid to run the same query for different selector.

Actually i tried 
    $('#setupHospitalCity, #setupLawContactCity').typeahead({
            minLength: 3,
            source: {
                brand: {
                    display: "city",
                    url: {
                        type: 'GET',
                        url: '/cities'
                    }
                }
            },
            callback: {
                onClick: function (node, a, item, event) {
                    console.log('onClick function triggered');
                    $('#setupHospitalCityId').val(item.cityId);
                    $('setupLawContactCity').val(item.cityId);
                }
            }
        });

None of the selector work.

If i create 2, that work..

$('#setupHospitalCity').typeahead({
            minLength: 3,
            source: {
                brand: {
                    display: "city",
                    url: {
                        type: 'GET',
                        url: '/cities'
                    }
                }
            },
            callback: {
                onClick: function (node, a, item, event) {
                    console.log('onClick function triggered');
                    $('#setupHospitalCityId').val(item.cityId);
                }
            }
        });
$('#setupLawContactCity').typeahead({
            minLength: 3,
            source: {
                brand: {
                    display: "city",
                    url: {
                        type: 'GET',
                        url: '/cities'
                    }
                }
            },
            callback: {
                onClick: function (node, a, item, event) {
                    console.log('onClick function triggered');
                    $('setupLawContactCity').val(item.cityId);
                }
            }
        });

Is there a way to avoid to do 2 query?

@running-coder

This comment has been minimized.

Owner

running-coder commented Aug 22, 2015

Hi marccollin I am indeed restricting the typeahead to be instanciated to one dom node only as the debug messages also says, I'll change this behavior no prob.

@marccollin

This comment has been minimized.

marccollin commented Aug 31, 2015

ok cool thanks

@marccollin

This comment has been minimized.

marccollin commented Sep 28, 2015

maybe in 2.2?

@running-coder running-coder added this to the 2.1.2 milestone Sep 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment