HTML5 developing mobile Web Apps--sencha Touch (7)

Source: Internet
Author: User

The Ext.domhelper component in Sencha Touch makes it easy to append or rewrite elements.

Demo Sample:

Launch:function () {function appenddom () {Ext.DomHelper.append (' My-div ', {id: ' url-list ', tag: ' ul ',    //Specify appended element kind CN : [//or children. Use array form to define child elements in an array {tag: ' Li ',, Cn:[{tag: ' A ', HTML: ' Google ', href: ' http://www.google.com '}]},{tag: ' Li ', Cn:[{tag: ' A ',// ... Omitted}]})}); var Mytoolbar = ext.create (' Ext.toolbar ', {docked: ' Top ', Items:[{xtype: ' button ', text: ' Append element ', handler:function () { Appenddom ();}}]}); var mypanel = ext.create (' Ext.panel ', {id: ' Mypanel ', HTML: ' <div id= ' my-div ' ></div> ', Items:[mytoolbar]}); Ext.Viewport.add (Mypanel);}


In addition to append, the ability to use the overwrite function to rewrite the contents of an element

Append and delete elements at the specified location, with the following method:

Innsertafter: appending elements after the target element

Innsertbefore: appending elements before the target element

Ext.domquery: Look for elements that can be selected using the CSS selector, such as:

Ext.DomQuery.select (' [class*= ' d '] ')// Select the element with class D

Ext.each: traversal of all appended elements

Ext.removenode: Deleting the specified element

Demo Sample:

var elems = Ext.DomQuery.select ('. Add ');

Ext.each (Elems,function (item,index,array) {//function : Current processing element, current processing element subscript, processing set;elems For the collection to be processed

Ext.removenode (item);

})

The meaning of the above code is: Delete all appended class named add element

HTML5 developing mobile Web Apps--sencha Touch (7)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.