Learning the Ajax framework of dojo: Section 7 -- first understanding of dojo widgets (with source code)

Source: Internet
Author: User

Widgets appear in more and more web applications. So, what is a widget? What are the markup methods used by widgets to declare them? Can widgets be dynamically created? What are the common methods and attributes of widgets ?...... This series of problems come to our minds. Let's take a look at them.

Learning 1: widget meaning
The English meanings of widgets are decorations or gadgets. Some Technical Documents translate them into widgets and use their English names directly here to avoid unnecessary confusion. The reasons why dojo provides the widget framework are as follows: one is to provide a better user experience, and the other is to help developers develop web applications quickly.

Learning 2: widget Declaration
The dojo widget provides a large number of UI controls that can be directly used. It also supports the declaration of the TAG method. Where,DojotypeIt is a key attribute for declaring a dojo widget. It specifies the widget type. For example:

<ButtonId = "button" dojotype = "button"> Create </button>.

 
You can also declare a Button widget in the page as follows: <button id = "button"Class="Dojo-button"> Create </button>; or <Dojo: buttonId = "button" caption = "CREATE"/>

 

Learning 3: dynamically create widgets in Dojo
Dojo supports dynamic creation of widgets, for exampleCodeDynamically create a Button widget and add it to the page:
Create Button widget
W =Dojo. widget. createwidget("Button", {caption: "CREATE "});
Dojo. Body (). appendchild(W. domnode );

 

 

Learning 4: common methods and attributes in widget Programming
In dojo, the features of widgets can be changed through programming. The following are common methods and attributes in widget programming.

    • Dojo. widget. byid (ID ):Retrieve widget objects by ID
    • Dojo. widget. createwidget:Dynamically create widget objects
    • Widgetobject. domnode:Dom node corresponding to the widget object
    • Widgetobject. containernode: Dom node corresponding to the container where the widget object is located
    • Widgetobject. Show ()/hide ():Show/hide Widgets
    • Widgetobject. Toggle ():Switch the display/hide status of Widgets
    • Widgetobject. isshowing ():Visible Widgets

 

Learning 5: Types of dojo Widgets

Currently, Dojo provides a wide range of widget libraries to meet the development needs of most web applications. Dojo widgetBy purposeIt can be divided into three categories:

    • Used for page layoutLayout widget
    • Used for form EnhancementForm widget
    • Implement common functionsGeneral Widgets

 

Summary:
The dojo widget framework has goodScalabilityDevelopers can develop custom widgets to reuse code.

Related Article

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.