city-picker
city-picker copied to clipboard
大神你好,用到ajax请求数据来初始化地址的问题,求指导
我请求完数据将省市填上去,但是在页面加载的时候dom已被初始化,导致city-picker.js里面
if (!data) { if (/destroy/.test(option)) { return; } options = $.extend({}, $this.data(), $.isPlainObject(option) && option); $this.data(NAMESPACE, (data = new CityPicker(this, options))); }
data已经有对象,所以不执行设置。 异步请求如下:
api.post("account", "single", { key: "123" }, function (result) { $("#city-picker").citypicker({ province: result.returnValue.province, city: result.returnValue.city }); });
我把input中的data-toggle="city-picker"去掉就解决了,没有这个就不会被初始化