Attila Naghi
Attila Naghi

Reputation: 2686

Select2 loading issue

Maybe this question is duplicated, but I still dont get why my select2 is not working and i need your help with this. This is my site. If you press ctrl +u you can see that the jquery library is loaded, the select2 script is loaded. I'm getting this error :$(...).select2 is not a function

and this is the js script :

$(document).ready(function() {

    $("#country").select2();

    $("#country").change(function(){
        $("#city option").remove();
        value = $(this).val();
        value = value.split("-");
        $.post( "register/get_cities_from_dd", { country_type: value[1]})
            .done(function( data ) {
                obj = JSON.parse(data);
                for(var i in obj) {
                    $('<option>', {
                        text     : obj[i].name,
                        value    : obj[i].id
                    }).prependTo('#city');
                }
        });
        $(".city").show();
    });

});

So, the question what Am i missing ?

Upvotes: 0

Views: 1304

Answers (1)

Raimond Kuipers
Raimond Kuipers

Reputation: 1146

You have loaded jQuery twice in your page. Remove the first, and then move all script tags to the bottom of the page and then it works.

Upvotes: 3

Related Questions