Creating Elements with Ext.DomHelper By Aaron Conran.

Slides:



Advertisements
Similar presentations
HTML DOM Part-II. Create Node We can create a node in JavaScript dynamically. There are 3 types of Node –Comment –Element –Text Node We can also create.
Advertisements

Diego Guidi - DotNetMarche. DOM tree is clunky to use No multiple handlers per event No high-level functions Browser incompatibilities = jQuery to the.
CT-376 jQuery Most popular javascript library today Latest version:
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
JQuery CS 380: Web Programming. What is jQuery? jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling,
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Document Object Model (DOM) JavaScript manipulation of the DOM.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 9: Defining Selectors.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
 Pseudo-elements  Centering  Tables  Classes and ids.
 CSS ids  Pages  Sites  HTML: class=“name”  Names may define format OR content › Either works  CAN apply multiple classes to the same tag  Multiple.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript II.
ExtJS Classes By Aaron Conran. Creating Classes Creating classes in JavaScript is easy as creating a constructor function and using the new keyword when.
Basics of HTML.
JS: Document Object Model (DOM)
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
Images (1) Three most popular formats – Graphics Interchange Format (GIF) – Joint Photographic Experts Group (JPEG) – Portable Network Graphics (PNG) –
Lab 3: Language Structures User Interface Lab: GUI Lab Sep. 9 th, 2014.
Form Tag How to use Form Tag Something NEW ? PARAMETER Attribute NAME Specifies the name for a form To specify which form to submit with JavaScript, this.
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.
JavaScript, Fourth Edition
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.
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.
HTML – Organizing Page Content. HTML Images img tag Required attribute: src
DOM Animation Changing the DOM objects over time.
DOM Document Object Model (DOM) SoftUni Team Technical Trainers Software University
HTML – Organizing Page Content. HTML Images img tag Required attribute: src
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
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.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
Are You Smarter Than a 5 th Grader? 1,000,000 5th Grade HTML 5th Grade Syntax 4th Grade HTML 4th Grade Syntax 3rd Grade HTML 3rd Grade Syntax 2nd Grade.
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.
Unit 13 –JQuery Basics Instructor: Brent Presley.
Links Building a Website Lesson 5. Links There are various ways to use links on a website: Link to other sites Link to other pages on the same site .
LING 408/508: Programming for Linguists Lecture 11 October 5 th.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Web Components Polymer. Agenda I want bootstrap : 3 Today.
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.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Wednesday, February 19, 2014 Session 4: JavaScript.
JavaScript Document Object Model 1. Document Object Model (DOM) JavaScript access to the elements of an HTML document. An object hierarchy Provides access.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
Drop-down box. Objectives Learn the HTML syntax of a drop-down list javascript properties of a list/menu: length options selectedIndex The location sub-object.
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.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
1 Objects In JavaScript. 2 Types of Object in JavaScript Built-in objects User Defined Objects Browser Object Document Object Model.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
EXTERNAL STYLESHEETS AND MORE HTML STYLING HTML and CSS part 2.
Introduction to Web Site Development Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript.
Introduction to JavaScript DOM Instructor: Sergey Goldman.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
THE DOM.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Website Design 3
Introduction to JavaScript
A second look at JavaScript
Office 365 Column Formatting (with Column Formatter)
IS 360 Understanding CSS Selectors
Working with Dynamic Content and Styles
Introduction to JavaScript
Chengyu Sun California State University, Los Angeles
Web Client Side Technologies Raneem Qaddoura
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Creating Elements with Ext.DomHelper By Aaron Conran

Creating Elements with the DOM The DOM provides us with methods such as document.createElement and HTMLElement.setAttribute as well as the innerHTML property to create elements Creating elements strictly through DOM methods can be tedious and verbose

Cross-browser Support Cross-browser inconsistencies eliminated ExtJS knows when to set properties, use setAttribute or use innerHTML depending on the browser Creating elements with only the DOM can be slow in certain browsers and using innerHTML is not allowed in others

ExtJS DomHelper The Ext.DomHelper class is a convenient utility class for working with the dom. It supports using both HTML fragments and the dom We’ll look at a comparison between strictly using the DOM and Ext’s DH Then we’ll go over the various config options of DH

Comparison // Using DOM methods var myEl = document.createElement('a'); myEl.href = ' myEl.innerHTML = 'My Link'; myEl.setAttribute('target', '_blank'); document.body.appendChild(myEl); // Using Ext’s DomHelper (DH) for short Ext.DomHelper.append(document.body, {tag: 'a', href: ' html: 'My Link', target: '_blank'});

DomHelper config DH Configs are used throughout the Ext library Such as: –autoCreate attribute of a ContentPanel or BasicDialog (Ext 1.x) –html attribute of a Panel or Window (Ext 2.x)

DH Configs DH Configs support the following custom attributes: –tag – this is the HTMLElement to create –cls – this is the CSS class to use –style – this is any inline CSS style info. This can be either an object literal or a quoted string –htmlFor – this is the HTMLElement’s for attribute –html – this is the inner html of the new element –cn/children – this is an array of children elements which also use DH configs

DH Configs DH configs also support all other HTML attributes Ex: –target –name –id –value –href

Ext.DomHelper DomHelper provides us methods to put our newly created elements in the DOM –append –insertAfter –insertBefore –insertFirst –overwrite

Ext.DH All of these methods have the same signature ( String/HTMLElement/Element el, Object/String o, [Boolean returnElement] ) –el – is the context element –o – is the DH config object –returnElement – is an optional boolean value to return an Ext.Element instead of an HTMLElement

DH append – adds the new element as the last child of the context element insertAfter – adds the new element directly after the context element insertBefore – adds the new element directly before the context element insertFirst – adds the new element as the first child of the context element overwrite – overwrites the inner html of the context element

Code: Existing markup: DH Complex Example

Result: