zoukankan      html  css  js  c++  java
  • KISSY的事件

    KISSY事件绑定与触发

        <body>
        <a id="a-target" href="#">登录</a>
        </body>
    
        KISSY.one('#a-target').on('click',function(){
    	  console.log('event fired');
        });
    	
        KISSY.one('#a-target').fire('click');
    

    支持冒泡

    	KISSY.Event.on('body','click',function(){
    	  console.log('body clicked');
    	});
    	
    	//模拟点击body中的一个a标签,会冒泡到父级body,body也会触发一个click事件
    	KISSY.one('#a-target').fire('click');
    

    触发通过传统方式添加的事件

            document.getElementById('a-target').onclick = function(){
    	  console.log('传统事件绑定');
    	};
    	
    	document.getElementById('a-target').addEventListener('click',function(){
    	  console.log('这个回调不会触发');
    	},false);
    
    	KISSY.one('#a-target').fire('click');
    

        KISSY不支持addEventListener或者attachEvent方式绑定的事件 

    接口统一的自定义事件

    	KISSY.one('#a-target').on('customeventa',function(){
    	  console.log('custom event firedx');
    	});
    	
    	KISSY.one('#a-target').fire('customeventa');
    

      

  • 相关阅读:
    起泡排序引申出的问题
    关于NPC和NP-Hard问题
    我的书单(更新中)
    OpenCV2学习笔记03:Qt中配置OpenCV环境
    Ubuntu 14.04为浏览器添加Flash插件
    CSS3基础
    HTML5进阶
    拖拽上传及读取文件实现
    生产者消费者模型
    进程
  • 原文地址:https://www.cnblogs.com/wewe/p/kissy.html
Copyright © 2011-2022 走看看