source: trunk/web/addons/job_monarch/lib/extjs/examples/core/templates.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 2.0 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.onReady(function(){
10
11    var data = {
12        name: 'Jack Slocum',
13        company: 'Ext JS, LLC',
14        address: '4 Red Bulls Drive',
15        city: 'Cleveland',
16        state: 'Ohio',
17        zip: '44102',
18        kids: [{
19            name: 'Sara Grace',
20            age:3
21        },{
22            name: 'Zachary',
23            age:2
24        },{
25            name: 'John James',
26            age:0
27        }]
28    };
29
30    var p = new Ext.Panel({
31        title: 'Basic Template',
32        width: 300,
33        html: '<p><i>Apply the template to see results here</i></p>',
34        tbar: [{
35            text: 'Apply Template',
36            handler: function(){
37
38                var tpl = new Ext.Template(
39                    '<p>Name: {name}</p>',
40                    '<p>Company: {company}</p>',
41                    '<p>Location: {city}, {state}</p>'
42                );
43
44                tpl.overwrite(p.body, data);
45                p.body.highlight('#c3daf9', {block:true});
46            }
47        }],
48
49        renderTo: document.body
50    });
51
52
53    var p2 = new Ext.Panel({
54        title: 'XTemplate',
55        width: 300,
56        html: '<p><i>Apply the template to see results here</i></p>',
57        tbar: [{
58            text: 'Apply Template',
59            handler: function(){
60
61                var tpl = new Ext.XTemplate(
62                    '<p>Name: {name}</p>',
63                    '<p>Company: {company}</p>',
64                    '<p>Location: {city}, {state}</p>',
65                    '<p>Kids: ',
66                    '<tpl for="kids" if="name==\'Jack Slocum\'">',
67                        '<tpl if="age &gt; 1"><p>{#}. {parent.name}\'s kid - {name}</p></tpl>',
68                    '</tpl></p>'
69                );
70                tpl.overwrite(p2.body, data);
71                p2.body.highlight('#c3daf9', {block:true});
72            }
73        }],
74
75        renderTo: document.body
76    });
77});
Note: See TracBrowser for help on using the repository browser.