Blog

Quizz: Working with the DOM

May 20, 2009 | English | By Hazel | No Comments | Leer en Espańol

The time has come to evaluate the knowledge we acquired about the DOM and how we can manipulate it in a very simple way by using the Ext JS Framework. Good luck!

Quizz: Working with the DOM
Author: Hazel

Excellent! You got the highest grade:

You had a few questions wrong, but you passed with:

I am sorry, you did not get the minimum grade, your grade is:

What is the correctly way to check if the DOM is ready to be used?

  • Ext.addEvent(document,’ready’,functionToExcute);
  • Ext.on(‘ready’,functionToExecute, scope );
  • Ext.onReady(functionToExecute, scope );
  • Ext.ready(functionToExecute, scope );

How can we get elements from the DOM?

  • Ext.getElement(‘id’);
  • Ext.get(‘id’);
  • Ext.getElementById(‘id’);
  • Ext.getCpm(‘id’);

What is the method Ext.fly?

  • Is the same as the method Ext.get, that’s why it shouldn’t even exists.
  • Allows you to select a DOM element using CSS and XPath selectors.
  • With this method we’re only going to have the DOM node and not an object Ext.Element.
  • Saves memory and makes our application more efficient since it reuses memory by not creating new instances of the object Ext.Element.

The purpose of the Ext.DomHelper component is:

  • Helps the DOM to be generated faster.
  • Displays the HTML in a graphical form.
  • Helps us to remove the nodes we don’t use anymore.
  • Makes it easy to handle the DOM to insert and create elements with JavaScript.

When executing the following code, what’s the value of the variable “items”?

var items = Ext.DomQuery.select('div[id=menu] > ul li a');
  • All the anchors that are inside of a div and have the id of “menu” and contains a node type “ul” that has a “li” element.
  • A list of nodes “li”.
  • The selector is incorrect.

When executing the following code, what’s the value of the variable “old”?

var old = Ext.DomQuery.selectNode('#menu ul li a[class*=item-selected]');
  • An anchor of where the mouse is.
  • An array of links that are found in the menu, encapsulated in a “li” list.
  • The link that contains a class called “item-selected” and it’s inside of the element “menu” encapsulated in a “li” list.
  • The variable doesn’t have a value because the expression is wrong.

Leave a Reply







Updates

RSS

Subscribe to our feeds to receive updates of our newest posts and free tutorials.

Site search

Maybe we have what you need, would you like to search first?

Donations

Would you buy me a cup of coffee? I am sharing my knowledge and time with you, help this project grow. Thank you!