Recommend Dojo Learning notes _dojo

Source: Internet
Author: User
Tags extend
Before referencing Dojo.js, it is a good idea to declare djconfig objects so that you can get the values you set when you load Dojo.js, although the dojo support after the 0.3 version is set after loading, it is strongly recommended that you declare the Djconfig code as the first script:
A complete Djconfig object is defined as follows (values are the default values of Dojo)
JS Code
var djconfig = {
Isdebug:false,
Debugcontainerid: "",
Bindencoding: "",
Allowqueryconfig:false,
Basescripturi: "",
Parsewidgets:true
Searchids: [],
Baserelativepath: "",
Libraryscripturi: "",
Iepreventclobber:false,
Ieclobberminimal:true,
Preventbackbuttonfix:true,

Debugcontainerid is also related to debugging, if not specified, debugging information will be directly used document.write output, which may damage the overall layout of the page, so you can specify any ID of the HTML element that can be used as the container as the Debugging information output container
Allowqueryconfig, this property indicates whether dojo allows the related properties in Djconfig to be read from the parameters of the page URL, and when the value is true, Dojo will first read the other properties of djconfig from the URL parameter, such as: http:// Server/dojodemo.htm?djconfig.debugcontainerid=divdebug
Basescripturi, generally do not need to set, Dojo will automatically according to the path you reference dojo.js set this value, for example, <script src= ". /dojo/dojo.js "type=" Text/javascript "></script&gt, the automatically obtained value is ... /dojo/
PS: If you have multiple projects that need to quote dojo.js at the same time, it is recommended that dojo be used as an independent project, using the absolute path when quoting.
Parsewidgets, this is to control whether dojo automatically resolves HTML elements with Dojotype as the corresponding widget, and if you don't use any widgets, it's recommended to set false to speed up dojo loading
Searchids, this is an array of strings that defines the IDs of all HTML elements that need to be resolved to the widget, and if the HTML element that is not in the ID is not parsed, then all elements with Dojotype will be parsed when the array is an empty array
There is also a bindencoding that is used to set the encoding for the default bind request.
Dojo.raise throws an exception
Dojo.errortostring converts an exception to a string
JS Code
try {
Dojo.raise ("Print Failed", New Error ("file does not exist");
catch (E)
{
Alert (Dojo.errortostring (e));
}
Isdebug is a useful property, and if set to true, then all dojo. Debug output is valid and should be set to true at development time and should be set to False when published.
1 Calculate the size of a block in HTML
JS Code
Dojo.style.getouterwidth/dojo.style.getouterheight
Dojo.style.getinnerwidth/dojo.style.getinnerheight
2 Modify CSS
JS Code
Dojo.html.addClass (node, className)
Dojo.html.prependClass (node, className)
Dojo.html.removeClass (node, className)
Dojo.html.replaceClass (node, className, Oldclassname)
3 animation
JS Code
FadeIn, Fadeshow, fadeout, Fadehide,
Wipein, Wipeout
Explode, implode
Highlight, Unhighlight
Example:
function Wipeout (elId) {
Dojo.lfx.wipeOut (ElId). Play ();
}
function Wipein (elId) {
Dojo.lfx.wipeIn (ElId). Play ();
}
function fadeout (elId) {
Dojo.lfx.html.fadeOut (ElId). Play ();
}
function FadeIn (elId) {
Dojo.lfx.html.fadeIn (ElId). Play ();
}
function Opacity (elId) {
Dojo.html.setOpacity (elId, 0.5);
}
function Opacityapp () {
$ ("#opacity"). Click (function () {
Opacity (' Fadeelm ');
});
}
function Fadeinapp () {
$ ("#fadein"). Click (function () {
FadeIn (' Fadeelm ');
});
} Dojo.lang module:
Dojo.lang.mixin adds an object's methods and properties to another object:
JS Code
var S1 = {Name: "Testobj", Test1:function () {alert ("This is test1!");}
var s2 = {value:1000, test2:function () {alert ("This is test2!");}
var d = {};
Dojo.lang.mixin (d, S1, S2); After implementation D has all the properties and methods of S1 and S2 d.test1 ();
Dojo.lang.extend extends methods and properties for the specified class's prototype:
JS Code
TestClass = function () {};
Dojo.lang.extend (TestClass, {name: "Demo", Test:function () {alert ("test!");});
var o = new TestClass ();
TestClass There was no test method, but extend later there was a test method o.test ();
Dojo.lang.find=dojo.lang.indexof finds the location of the specified object in the specified array:
JS Code
var arr = [1,2,3,3,2,1];
Dojo.lang.find (arr, 2); would return 1
Dojo.lang.extrasdojo.lang.setTimeout executes the specified method after a specified time delay:
JS Code
function OnTime (msg) {Dojo.debug (msg)}
Dojo.lang.setTimeout (onTime, 1000, "test"); 1 seconds to output debug information "test"
DOM Operations
JS Code
Dojo.dom.isNode
Dojo.dom.getTagName
Dojo.dom.firstElement
Dojo.dom.lastElement
Dojo.dom.nextElement
Dojo.dom.prevElement
Dojo.dom.moveChildren (Srcnode, Destnode, Trim)
Dojo.dom.copyChildren (Srcnode, Destnode, Trim)
Dojo.dom.removeChildren (node)
Dojo.dom.replaceChildren (node, newchild)
Dojo.dom.removeNode (node)
Dojo.dom.getAncestors
Dojo.dom.getAncestorsByTag
Dojo.dom.innerXML
Dojo.dom.createDocumentFromText
Dojo.dom.prependChild
Dojo.dom.insertAfter
Dojo.dom.insertAtPosition
Dojo.dom.textContent
I'd like to introduce you so much and have a nice weekend!

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.