@@ -33,7 +33,7 @@ window.util.toucher = window.util.toucher || function (dom){
33
33
* @param [function] 符合条件的事件被触发时需要执行的回调函数
34
34
*
35
35
*/
36
- function ON ( eventName , a , b ) {
36
+ function ON ( eventStr , a , b ) {
37
37
this . _events = this . _events || { } ;
38
38
var className , fn ;
39
39
if ( typeof ( a ) == 'string' ) {
@@ -43,16 +43,20 @@ window.util.toucher = window.util.toucher || function (dom){
43
43
className = null ;
44
44
fn = a ;
45
45
}
46
- //事件名存在且callback合法,进行监听绑定
47
- if ( eventName . length > 0 && typeof ( fn ) == 'function' ) {
48
- //事件堆无该事件,创建一个事件堆
49
- if ( ! this . _events [ eventName ] ) {
50
- this . _events [ eventName ] = [ ] ;
46
+ //检测callback是否合法,事件名参数是否存在·
47
+ if ( typeof ( fn ) == 'function' && eventStr && eventStr . length ) {
48
+ var eventNames = eventStr . split ( / \s + / ) ;
49
+ for ( var i = 0 , total = eventNames ; i < total ; i ++ ) {
50
+ var eventName = eventNames [ i ] ;
51
+ //事件堆无该事件,创建一个事件堆
52
+ if ( ! this . _events [ eventName ] ) {
53
+ this . _events [ eventName ] = [ ] ;
54
+ }
55
+ this . _events [ eventName ] . push ( {
56
+ 'className' : className ,
57
+ 'fn' : fn
58
+ } ) ;
51
59
}
52
- this . _events [ eventName ] . push ( {
53
- 'className' : className ,
54
- 'fn' : fn
55
- } ) ;
56
60
}
57
61
58
62
//提供链式调用的支持
0 commit comments