commit extjs-2.2.1
[extjs.git] / examples / remoteload / EmployeeDetails.js
1 /*\r
2  * Ext JS Library 2.2.1\r
3  * Copyright(c) 2006-2009, Ext JS, LLC.\r
4  * licensing@extjs.com\r
5  * \r
6  * http://extjs.com/license\r
7  */\r
8 \r
9 Ext.ns('App');\r
10 \r
11 App.EmployeeDetails = Ext.extend(Ext.Panel, {\r
12         startingText: 'Please select an employee.',\r
13         initComponent: function() {\r
14                 this.tpl = Ext.XTemplate.from('employeeDetailTpl');\r
15                 this.html = this.startingText;\r
16                 App.EmployeeDetails.superclass.initComponent.call(this);\r
17         },\r
18         load: function(config) {\r
19                 var config = config || {};\r
20                 Ext.apply(config, {\r
21                         url: this.url,\r
22                         success: this.onLoad,\r
23                         failure: this.onFailure,\r
24                         scope: this\r
25                 });\r
26                 this.getEl().mask('Loading...');\r
27                 Ext.Ajax.request(config);\r
28         },\r
29         onLoad: function(response, opts) {\r
30                 var json = Ext.decode(response.responseText);\r
31                 this.tpl.overwrite(this.body, json);\r
32                 this.getEl().unmask();\r
33         },\r
34         onFailure: function() {\r
35                 this.getEl().unmask();\r
36                 Ext.Msg.alert('Fail', 'Request failed.');\r
37         }\r
38 });\r
39 Ext.reg('employeedetails', App.EmployeeDetails);\r