Home > Web Front-end > JS Tutorial > body text

Recommended dojo study notes_dojo

WBOY
Release: 2016-05-16 19:16:04
Original
1140 people have browsed it

Before referencing dojo.js, it is best to declare the djConfig object so that the set value can be obtained when dojo.js is loaded. Although dojo supports setting after loading after version 0.3, it is strongly recommended that you declare the code of djConfig as the first A piece of script:
A complete djConfig object is defined as follows (the values ​​​​are all dojo’s default values)
js code
var djConfig = {                                                                                                                                                                                                                              
bindEncoding: "",
allowQueryConfig: false,
baseScriptUri: "",
parseWidgets: true
searchIds: [],
baseRel ativePath: "",
libraryScriptUri: "",
iePreventClobber: false,
ieClobberMinimal: true,
preventBackButtonFix: true,

debugContainerId is also related to debugging. If not specified, the debugging information will be directly used in the document .write output, which may destroy the overall layout of the page, so you can specify the id of any HTML element that can be used as a container as a debug information output container
allowQueryConfig. This attribute indicates whether dojo allows reading from the parameters of the page url. Get the relevant attributes in djConfig. When the value is true, dojo will give priority to reading other attributes of djConfig from the url parameter, such as: http://server/dojoDemo.htm?djConfig.debugContainerId=divDebug
baseScriptUri, generally No setting is required. Dojo will automatically set this value according to the path you use to reference dojo.js. For example,
, and the automatically obtained value is ../dojo/
ps: If you have multiple projects that need to be referenced at the same time For dojo.js, it is recommended to treat dojo as an independent project and use the absolute path when referencing it.
parseWidgets, this can control whether dojo automatically parses html elements with dojoType into corresponding widgets. If you No Widget is used. It is recommended to set it to false to speed up the loading speed of dojo.
searchIds, which is a string array that defines the IDs of all HTML elements that need to be parsed as widgets. If the ID is not in the HTML element, it will not be used. Parsed, when the array is an empty array, all elements with dojoType will be parsed
There is also a bindEncoding, which is used to set the default binding request encoding method.
dojo.raise throws an exception
dojo.errorToString converts the exception into a string
js code
try {      
 dojo.raise("Printing failed", new Error("The file does not Exists"));
} catch(e)
{ alert(dojo.errorToString(e));
}
isDebug is a very useful attribute. If set to true, Then all the output of dojo.Debug is valid and should be set to true when developing and false when publishing.
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, unhigh light 
Example:                                                                       wipeOut(elId                                                                                                                                         dojo.lfx. In(elId, 300).play();
} }
function fadeOut(elId){
dojo.lfx.html.fadeOut(elId, 300).play();
} wipe
function fadeIn(elId){
dojo.lfx.html.fadeIn(elId, 300).play();
} function opacity(elId){
dojo.html.setOpac ity(elId , 0.5);                                                                                        });  
}                                                                                                                                                                 . lang module:
dojo.lang.mixin adds methods and properties of one object 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 execution, d will have all the attributes and methods of s1 and s2 d.test1();
dojo.lang.extend is the prototype of the specified class Extension methods and attributes:
js code
TestClass = function() {};
dojo.lang.extend(TestClass, {name: "demo", test: function(){alert("Test! ");}});
var o = new TestClass();
dojo. lang.find=dojo.lang.indexOf finds the position of the specified object in the specified array:
js code
var arr = [1,2,3,3,2,1];
dojo.lang .find(arr, 2); //will return 1
dojo.lang.extrasdojo.lang.setTimeout executes the specified method after delaying the specified time:
js code
function onTime(msg){dojo.debug (msg)}
dojo.lang.setTimeout(onTime, 1000, "test"); //Debug information "test" will be output after 1 second
DOM operation
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)                                                                       . insertAfter                                                                                              

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template