data-dojo-mixins

Let each Widget have a plug-in mechanism: new data-dojo-mixins attribute

The plug-in mechanism is a best practice for building flexible and extensible applications, and now Dojo fully implements the plug-in mechanism through this brand-new property , So that Dojo’s Widget can flexibly determine the features you need when using it. Because of the existence of this attribute, the development of Widget will also be more modular, and each group of functions can be defined independently. When using, decide whether to enable this function according to the specific usage scenario. For example, the recently popular TreeMap component is provided in dojox. The module dojox/treemap/TreeMap itself only contains the most basic functions. For keyboard support, color block splitting and other functions are implemented through pluggable modules: dojox/treemap/Keyboard and dojox/treemap/DrillDownUp modules. Such an accessory module can be understood as a plug-in. Add it to the data-dojo-mixins attribute as needed to enable the corresponding function.

Here, data-dojo- The modules separated by commas in the mixins attribute can be regarded as plug-ins. Not only can new controls use the plug-in mechanism to add new functions to existing components, they can also be implemented by providing plug-ins. Compared to deriving a new class to implement this function, plug-ins are universal. For example: Suppose you want to add voice recognition to the TextBox, Select and other form controls under dijit/form, you may only need to write a my/voice/Recognizer module, so that all Widgets with an interface such as set(‘value’, value) will be This component can be selected flexibly, without the need to derive a new class for each Widget. For the functional combination of multiple plug-ins, it is more obvious that data-dojo-mixins will be very suitable.

What we see now is the Widget created in the declarative way. We can make good use of data-dojo-mixins to implement the plug-in mechanism. What about dynamically created Widgets? In fact, this can be achieved before 1.8:

var treemap = new (declare(['dojox/treemap/TreeMap','dojox/treemap/Keyboard','dojox/treemap/DrillDownUp']))(arguments); 

The flexibility of modules has always been Dojo’s focus. Since the introduction of AMD, Dojo has proposed the concept of base-less, that is, the Dojo framework can be configured without any core libraries, and all modules are loaded on demand. This requires the functions provided by each module to be independent and streamlined, so as to achieve the goal of only loading the required code in the end. The data-dojo-mixins attribute can help us split the function and modularize it to the extreme. This is undoubtedly an eye-catching concept and practice in the current environment where JavaScript code is generally bloated.

========================

Load external dialog Content, such as the sample content in Listing 20:

Listing 20. Dialog box content (dialog-data.html)

< pre style="padding:0px; margin-top:0px; margin-bottom:1em; font-family:'Courier New',monospace; width:613.796875px; overflow:auto; background-color:rgb(247,247,247); color :rgb(51,51,51); line-height:25px">

Rain Alert
Do you have an umbrella?

Use _ContentPaneMixin to load the dialog box content, such as Shown in Listing 21:

Listing 21. Load external dialog content

 

The example in Listing 21 uses the data-dojo-mixins attribute to dynamically add the functionality of dojox.mobile.ContentPane to SimpleDialog, which is also a new feature in Dojo 1.8.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 558 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.