Considerations for adding events using Dojo.connect ()

Source: Internet
Author: User

It is convenient to add event handlers using Dojo.connect (), without having to think about cross-browser issues. However, to use this method correctly, there are a few questions to keep in mind:
1, using Dojo.byid () to get the DOM element, and Dijit.byid () to get the Dojo widget, these two points are fundamentally different.
2, the case of the event name is critical, if the DOM element is added to the event handler, the event name is lowercase, such as the Click event, you can use the click or on

Click OK, but be sure to lowercase the C letter; If you add an event handler to the Dojo widget, the event name must conform to the Dojo specification, such as the Click event, must be written as onclick, the letter O is lowercase, and the letter C must be capitalized.
3. If you want to add an event handler to a page element, be sure to use Dojo.byid () or Dijit.byid () to get the element reference, depending on whether the element is a DOM element or a dojo widget. If it is used, the result may be a failure or an abnormal condition.
Note the above questions, the correct use of the good Dojo.connect () method is not a problem.
Example one:
<button id= "BTN" >click me!</button>
<script type= "Text/javascript" >
Dojo.connect (Dojo.byid (' btn '), ' onclick ', null, handler);
</script>
Example two:
<button id= "btn" dojotype= "Dijit.form.Button" label= "click me!" ></button>
<script type= "Text/javascript" >
Dojo.connect (Dijit.byid (' btn '), ' OnClick ', null, handler);
</script>----------------------------------------------------------------------------------------------- --------Note: This article is reproduced in: Http://blog.163.com/[email protected]/blog/static/732525372011101715346673

Considerations for adding events using Dojo.connect ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.