 |
ต้องการสอบถามเรื่อง dojo และ jquery อ่ะครับบบบบบบบบบบบ |
|
 |
|
|
 |
 |
|
โอ มีคนสนใจ dojo เหมือนกันด้วย
อธิบายแบบเร็ว ๆ นะ
dojo และ jQuery ต่างเป็น ajax framework เหมือนกันและทำอะไรได้เหมื่อน ๆ กัน ต่างกันตรงที่
dojo จะเขียน ออกแนว oop แต่ jquery จะเขียนแนว function หรือ oop ก็ได้ และเนื่องจากการที่ dojo เน้นการเขียนแบบ oop
ดังนั้นในการทำงานที่เหมือนกัน dojo จะใช้จำนวนบรรทัดในการเขียนที่มากกว่า jquery
ก่อนอื่นให้ไป download ที่ http://download.dojotoolkit.org
อันนี้เป็นวิธีการเรียกใช้ dojo
Code
<script type="text/javascript" src="/js/dojo/dojo.js">
</script>
การเริ่มใช้
การเริ่มใช้งานสิ่งที่ต้องหัดใช้ด่วนที่สุดคือการเลือก element ต่าง ๆ และนี้จะเป็นสิ่งแรกที่เรียนรู้เมื่อใช้ dojo พยายามทำความเข้าใจให้ดี
เป็นมันเป็นพื้นฐานสุด ๆ ของการใช้ dojo
Code
dojo.query(query:String, root: String|DOMNode?, listCtor:Function?):NodeList
query:String เป็นข้อมูลที่ต้องการค้นหา
root จะมีหรือไม่ก็ได้(optional) กำหนดค่าเป็น id หรือ domnode ที่จะมีผลกระทบต่อการ query
listCtor:Function listCtor ย่อมาจาก list constructor กำหนดค่าเป็น function ที่จะทำงานหลังการ query
:NodeList คืนค่่าเป็น NodeList หรือจากที่ query
ตัวอย่างรูปแบบที่กำหนดให้ query
Code
Class ".foo" or ".bar"
ID selectors "#foo"
Node type (such as tag names) "span"
Descendant combinatory "ul li"
Child combinator "div > span"
Universal selector *
Adjacent sibling combinator +
General sibling combinatory ~
Attribute presence [foo]
Attribute with exact value [foo='bar']
Attribute with a value in a whitespace separated list of words [foo~='bar']
Attribute begins with value [foo^='bar']
Attribute ends with value [foo$='bar']
Attribute with at least one substring instance value [foo*='bar']
Structural pseudo-classes :first-child, :last-child, :only-
child, :empty, :checked, :nth-
child(n), :nth-child(2n+1), :nth-
child(even), nth-child(odd),
:not(...)
ตัวอย่างการเขียนโดยไม่ใช้ dojo
Code
var highlight = function(class, color)
{
var divs = document.getElementById('elements').childNodes;
var fooDivs = new Array();
for(var i=0; i<divs.length; i++)
{
if(divs[i].className.match(class)==true)
{
fooDivs.push(divs[i]);
}
}
for(var i=0; i<fooDivs.length; i++)
{
fooDivs[i].style.backgroundColor = color;
}
}
เขียนโดยใช้ dojo
Code
var highlight = function(query, color)
{
dojo.query(query).style("backgroundColor",color);
}
|
 |
 |
 |
 |
Date :
2011-03-10 04:24:24 |
By :
SpiderManDark |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าเปนการใช้ theme หรือ form ของ dojo อ่ะครับ เค้าทำกันยังไง
|
 |
 |
 |
 |
Date :
2011-03-10 13:58:06 |
By :
noobilian |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าจะเปลี่ยนไฟล์ dojo ให้เป็น jquery ต้องทำยังไงบ้างค่ะ ขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
2013-06-26 17:33:20 |
By :
hibino |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เคยใช้แต่ PEPO
|
 |
 |
 |
 |
Date :
2013-06-27 06:37:56 |
By :
fuckingshit |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|