首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Learning Dojo - 3.3 Asynchronous Programming

2012-11-21 
Learning Dojo-- 3.3 Asynchronous Programming1.Handling dom eventsa.Define the event handlerfunction

Learning Dojo -- 3.3 Asynchronous Programming
1.Handling dom events

  a.Define the event handler

        function alertSomeEvent(){  alert("someEvent");  }

  b.Connect some event to the handler
   function connect(){      dojo.connect(dojo.byId("someButton"),"click", alertSomeEvent);       }

  c.Register this connection when dom tree initialization is done
        
dojo.addOnLoad(connect);


2.Handling user-defined events

   It's similar with handling dom events, only that the events here user-defined functions

3.Publish-Subcribe Framework
    <!--I'm going to publish this topic when I am clicked -->    <button onclick="javascript:dojo.publish('someTopic')">publish</button>

    //A topic handler will handle this topic     dojo.subscribe("someTopic", handleSomeTopic);    //And it will handle the topic like this,       function handleSomeTopic(){    alert("some topic is published");  }}  



4.Advanced Topic
   Do the research by yourself if you need them
    a.Bubbling/Capturing  (Event Propagation)
    b.dojo.Deferred  (multi-thread programming)

热点排行