code
var selector1 = $('#city-picker-selector1').cityPicker({
dataJson: cityData,
renderMode: true,
search: false,
autoSelected: false,
code: 'cityCode',
level: 4,
onChoiceEnd: function() {
console.log(this.values)
}
});
// 设置城市
selector1.setCityVal('广东省, 广州市, 天河区, 天园街道');
// 省份选择的回调
$('#city-picker-selector1').on('choose-province.citypicker', function(event, tagert, values) {
console.log(values);
});
// 城市选择的回调
$('#city-picker-selector1').on('choose-city.citypicker', function(event, tagert, values) {
console.log(values);
});
// 区县选择的回调
$('#city-picker-selector1').on('choose-district.citypicker', function(event, tagert, values) {
console.log(values);
});
// 街道选择的回调
$('#city-picker-selector1').on('choose-street.citypicker', function(event, tagert, values) {
console.log(values);
});
code
var selector2 = $('#city-picker-selector2').cityPicker({
dataJson: cityData,
renderMode: true,
search: false,
autoSelected: true,
code: 'cityCode',
level: 3,
onChoiceEnd: function() {
console.log(this.values)
}
});
// 设置城市
selector2.setCityVal('广东省, 广州市, 天河区');
code
var selector3 = $('#city-picker-search').cityPicker({
dataJson: cityData,
renderMode: true,
search: true,
autoSelected: true,
keyboard: true,
level: 2,
onChoiceEnd: function() {
console.log(this.values)
}
});
code
var selector4 = $('#city-picker-search2').cityPicker({
dataJson: cityData,
renderMode: true,
search: true,
autoSelected: true,
keyboard: true,
level: 1,
onChoiceEnd: function() {
console.log(this.values)
}
});
code
var select = $('.city-picker-select').cityPicker({
dataJson: cityData,
renderMode: false,
autoSelected: true,
level: 4,
onChoiceEnd: function() {
console.log(this.values)
}
});
// 设置城市
select.setCityVal('山西省, 太原市, 小店区, 坞城街道');