Comments (2)
area2.init({ 'trigger': '#demo2', 'valueTo': '#value2', 'keys': { id: 'value', name: 'text' }, 'type': 2, 'data': [provs_data, citys_data, dists_data], 'ok':function (value) { console.log(value) }, 'close':function () { console.log(0) } });
源码:
341行:
if(this.valueTo){ this.valueTo.value= provinceCode +((cityCode)?(',' + cityCode):('')) + ((countyCode)?(',' + countyCode):('')); } _self.params.ok&&_self.params.ok([provinceText,cityText,countyText]); _self.close(e); }, close: function(e) { e.preventDefault(); var _self = this; var evt = new CustomEvent('input'); _self.trigger.dispatchEvent(evt); document.body.removeChild(_self.gearArea); _self.gearArea=null; _self.params.close&&_self.params.close(); }
ok返回选择地址的数组
from larea.
+1 同建议增加回调,可以自主控制结果
var addrText = provinceText + ((cityText)?(',' + cityText):(''))+ ((countyText)?(',' + countyText):(''));
var addrCode = provinceCode +((cityCode)?(',' + cityCode):('')) + ((countyCode)?(',' + countyCode):(''));
if (this.params.finish && typeof this.params.finish === 'function') {
this.params.finish(addrText, addrCode, [provinceVal, cityVal, countyVal]);
} else {
addrText = addrText.replace(/县,|市辖区,/ig, '').replace(/,/ig, ''); // 直辖市结果处理
_self.trigger.value = addrText;
_self.value = [provinceVal, cityVal, countyVal];
if(this.valueTo){
this.valueTo.value= addrCode;
}
}
这样,在init
的时候
var area = new LArea();
area.init({
'trigger': '#trigger',
'keys': {
id: 'id',
name: 'name'
},
'type': 1,
'data': LAreaData,
finish: function(text, code, value) {
// 自己选择显示结果
}
});
from larea.
Related Issues (20)
- 如何获取选中的值
- Uncaught TypeError: Cannot read property 'nodeType' of undefined
- 样式我需要自己修改,但是修改完之后,省市区的位置都对不上了
- 滑动时点击确定报错
- 在个别手机上的省市区的排列乱了的问题
- 如何在更改样式行高后,滑动的结束后能够停留在一行?
- 用commonjs写法怎么模块的导出呢?
- ios下第二次点击input触发失败 HOT 1
- 大神本人小鸟一只 妄图修改三级为二级屡屡碰壁还请指点!!!!急得一匹!!!
- android部分机型不能滑动huawei6,vivo Y67是什么原因 HOT 1
- 这个是必须三级,如果是二级,或是一级怎么办呢? HOT 1
- 能不能直接遍历后台传回来的数据 HOT 2
- Uncaught TypeError: Cannot read property 'querySelectorAll' of null at MobileArea.setGearTooth (LArea.js:278)
- 移动端触发不了,PC完全没问题。急,大神求解答啊
- 当我选择地址的时候点击下面的地址会有一个报错,导致页面 HOT 2
- 手机端调不起来啊?支持手机吗
- 性能问题
- 不支持点击事件 HOT 1
- 移动端呼出时会出现按键的情况
- 无限循环报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from larea.