读书人

Learning Dojo - 3.3 Asynchronous P

发布时间: 2012-11-21 08:23:25 作者: rapoo

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)

读书人网 >编程

热点推荐