Created
July 13, 2015 16:10
-
-
Save e-vural/76aa8ec83d83b9e7c9d1 to your computer and use it in GitHub Desktop.
Select 2 Şehir İlce Seçimi Jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
il gönderdik | |
*/ | |
$("#il").select2({ | |
maximumSelectionLength: 1, | |
allowClear: true, | |
theme: "bootstrap", | |
ajax:{ | |
url: Routing.generate('sehir'), | |
dataType: 'json', | |
delay: 250, | |
data: function (params){ | |
return { | |
q: params.term, | |
page: params.page | |
}; | |
}, | |
processResults: function (data) { | |
return { | |
results: $.map(data, function (obj) { | |
return {id: obj.baslik, text: obj.baslik}; | |
}) | |
}; | |
} | |
}, | |
//escapeMarkup: function(markup) {return markup}, | |
minimumInputLength: 2, | |
//templateResult: formatRepo, // omitted for brevity, see the source of this page | |
//templateSelection: formatRepoSelection, // omitted for brevity, see the source of this page | |
placeholder: "Ara..." | |
}); | |
/*ilçe seçimi için ilin idsini aldık*/ | |
$('#il').change(function() { | |
var il = $('#il').val() | |
var il2='il='+il | |
$(".js-example-placeholder-single2").select2({ | |
theme: "bootstrap", | |
disabled:false, | |
maximumSelectionLength: 1, | |
allowClear: true, | |
placeholder: "Ara...", | |
ajax:{ | |
url: Routing.generate('ilceler'), | |
dataType: 'json', | |
delay:250, | |
data:function (params){ | |
return { | |
il:il, | |
q: params.term, | |
page: params.page | |
}; | |
}, | |
processResults: function (data) { | |
return { | |
results: $.map(data, function (obj) { | |
return {id: obj.baslik, text: obj.baslik}; | |
}) | |
}; | |
}, | |
traditional: true | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment