Navigating the DOM with ExtJS By Aaron Conran. Document Object Model The Document Object Model or DOM is a standard to represent HTML, XHTML and other.

Slides:



Advertisements
Similar presentations
1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
Advertisements

XML CS What is XML?  XML: a "skeleton" for creating markup languages  you already know it!  syntax is identical to XHTML's: content  languages.
JavaScript and AJAX Jonathan Foss University of Warwick
JQuery CS 380: Web Programming. What is jQuery? jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling,
LIBRARIES AS LANGUAGES: TYPECHECKING JQUERY PROGRAMS Benjamin Lerner Liam Elberty Jincheng Li Shriram Krishnamurthi.
Objectives Define the characteristics of good design. Test browsers for HTML5 and CSS3 compatibility. Define CSS and its relationship with HTML. Glance.
1 Extensible Markup Language: XML HTML: portable, widely supported protocol for describing how to format data XML: portable, widely supported protocol.
Document Object Model. Lecture 18 The Document Object Model (DOM) is not a programming language It is an object-oriented model of web documents Each.
1 Extensible Markup Language: XML HTML: portable, widely supported protocol for describing how to format data XML: portable, widely supported protocol.
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
1 Extensible Markup Language: XML HTML: widely supported protocol for formatting data XML: widely supported protocol for describing data XML is quickly.
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Cos 381 Day 10.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 2.
1 XML Data Management 4. Domain Object Model Werner Nutt.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
JS: Document Object Model (DOM)
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 4 - XML.
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
JavaScript Frameworks Presented by Kyle Goins Also see:
. Taught by: Muhammad Ali Baloch midahot. WHAT IS JQUERY JQuery is a fast, small, and feature-rich JavaScript library. Simplifies the interaction between.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Introduction to the Document Object Model Eugenia Fernandez IUPUI.
Markup basics. Markup languages add commentary to text files –so that the commentary can be ignored if not understood eg HyperText Markup Language –adds.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Creating Elements with Ext.DomHelper By Aaron Conran.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Document Object Model. Back to the DOM… Javascript and the DOM  Originally, the Document Object Model (DOM) and Javascript were tightly bound  Each.
XML DOM.
ExtJS Events By Aaron Conran. Events Events describe when a certain action happens. This could be a user action, a response to an Ajax call, etc. Events.
LING 408/508: Programming for Linguists Lecture 11 October 5 th.
Host Objects: Browsers and the DOM
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
Document Object Model CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from.
Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Making web pages interactive with JavaScript.
.. WHAT IS JQUERY JQuery is a fast, small, and feature-rich JavaScript library. Simplifies the interaction between HTML and JavaScript. The jQuery library.
Programming Web Pages with JavaScript
Unit 4 Representing Web Data: XML
CHAPTER 5 DOCUMENT OBJECT MODEL
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
Applied Online Programming
Introduction to the Document Object Model
DOM Document Object Model.
Document Object Model (DOM): Objects and Collections
..
JavaScript and the DOM MIS 2402 Jeremy Shafer Department of MIS
CSc 337 Lecture 9: The DoM tree.
Chengyu Sun California State University, Los Angeles
Murach's JavaScript and jQuery (3rd Ed.)
JavaScript and the DOM MIS 2402 Maxwell Furman Department of MIS
Presentation transcript:

Navigating the DOM with ExtJS By Aaron Conran

Document Object Model The Document Object Model or DOM is a standard to represent HTML, XHTML and other XML formats. The DOM is represented as a tree within the browser and provides access to all node’s on the current page

DOM Nodes DOM Nodes can be of various types The type of node can be determined by a property called nodeType The most frequently used nodeType’s are: –document.ELEMENT_NODE (1) –document.TEXT_NODE (3) –document.DOCUMENT_NODE (9) From here on we will refer to DOM node’s with a nodeType of ELEMENT_NODE as an HTMLElement.

DOM Pointers Each dom node has 5 pointers which allow you to navigate through the DOM –parentNode –previousSibling –nextSibling –firstChild –lastChild These pointers will return null if there is no associated dom node

DOM Pointers Finding related elements with only DOM pointers may prove frustrating ExtJS allows you to find related elements much easier by –eliminating cross-browser inconsistencies –ignoring empty textnodes created by formatted markup –implementing CSS/XPath selection

Retrieving an HTMLElement With standard JavaScript we would retrieve an HTMLElement by: var myEl = document.getElementById(‘myID’); With Ext we can retrieve the same HTMLElement by: var myEl = Ext.getDom(‘myID’);

Ext.Element Ext.Element is a wrapper class around HTMLElement which provides functionality for manipulating, creating and finding other Elements Ext.Element maintains cross-browser compatibility Ext.Element has an HTMLElement property named dom –‘has’ signifying that Ext.Element uses aggregation rather than inheritance

Getting an Element To retrieve an Ext.Element: var myEl = Ext.get(‘myID’); To directly access the HTMLElement of myEl use the dom property: myEl.dom.innerHTML

Searching for Related Elements Given the following markup: Task: Find the fieldset element with only a reference to the ‘ ’ element. Code: var el = Ext.get(‘ ’).up(‘fieldset’); CSS SelectorInput’s ID

up or findParentNode up public function up( String selector, [Number/String/HTMLElement/Element maxDepth] ) Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child). This is a shortcut for findParentNode() that always returns an Ext.Element. Parameters: –selector : StringThe simple selector to test –maxDepth : Number/String/HTMLElement/Element(optional) The max depth to search as a number or element (defaults to 10 || document.body) Returns: Ext.Element The matching DOM node (or null if no match was found) This method is defined by Element.

CSS/Xpath Selectors ExtJS supports most CSS3 Selectors and Xpath Examples –div.myClass –body –a.window –Div:only-child –div:last-child –div > div

Methods for Searching the DOM child contains down findParent findParentNode (or up) getNextSibling getPrevSibling is query select up