以下代码定义了一个用于更新文章或添加文章的窗体:
1Cms.ModifyArticleWindow = Ext.extend(Ext.Window, {
2 title: '添加文章',
3 modal: true,
4 layout: 'fit',
5 width: 650,
6 height: 600,
7 md: 'add',
8 bufferResize: false,
9
10 initComponent: function() {
11 var url = '/admin/addarticle';
12 var categoryId = this.categoryId;
13 var articleId;
14 var title;
15 var author;
16 var isNewsPhotos = false;
17 var photoUrl;
18 var summary;
19 var content;
20
21 if (this.md && this.md == 'update') {
22 this.title = '修改文章';
23 url = '/admin/updatearticle';
24 articleId = this.article.Id;
25 title = this.article.Title;
26 author = this.article.Author;
27 isNewsPhotos = this.article.IsNewsPhotos;
28 photoUrl = this.article.PhotoUrl;
29 summary = this.article.Summary;
30 content = this.article.Content;
31 }
32
33 var win = this;
34 var update = this.onUpdate;
35
36 this.items = [{
37 xtype: 'form',
38 url: url,
39 width: 640,
40 height: 400,
41 labelWidth: 50,
42 monitorValid: true,
43 frame: true,
44 items: [{
45 xtype: 'hidden',
46 name: 'categoryId',
47 value: categoryId
48 }, {
49 xtype: 'hidden',
50 name: 'Id',
51 value: articleId
52 }, {
53 xtype: "textfield",
54 fieldLabel: "标题",
55 name: 'title',
56 anchor: "100%",
57 allowBlank: false,
58 value: title
59 }, {
60 xtype: "textfield",
61 fieldLabel: "作者",
62 name: 'author',
63 anchor: "100%",
64 value: author
65 }, {
66 layout: "column",
67 items: [{
68 columnWidth: 0.3,
69 layout: "form",
70 items: {
71 xtype: "checkbox",
72 蟆 ?fieldLabel: "是否是图片新闻",
73 0 name: 'isNewsPhotos',
74 inputValue: true,
75 checked: isNewsPhotos
76 }
77 }, {
7 8 columnWidth: 0.7,
79 layout: "form",
80 items: {
81 xtype: "textfield",
82 fieldLabel: "图片路径",
83 name: 'photoUrl',
84 anchor: "90%",
85 value: photoUrl
86 }
87}]
88 }, {
89 xtype: 'htmleditor',
90 fieldLabel: '摘要',
91 name: 'summary',
92 height: 100,
93 anchor: "98%",
94 value: summary
95 }, {
96 xtype: 'htmleditor',
97 fieldLabel: '内容',
98 name: 'content',
99 height: 270,
100 anchor: "98%",
101 allowBlank: false,
102 value: content
103}],
104 buttons: [{
105 text: '确定',
106 formBind: true,
107 handler: update,
108 scope: win
109 }, {
110 text: '取消',
111 handler: function() {
112 win.close();
113 }
114}]
115
116}];
117 Cms.ModifyArticleWindow.superclass.initComponent.call(this);
118 //定义了保存后执行的事件
119 this.addEvents('afterSave');
120 },
121 onUpdate: function() {
122 var win = this;
123 var form = this.items.items[0].form;
124
125 form.submit({
126 method: 'POST',
127 waitTitle: '',
128 waitMsg: '正在处理',
129 success: function(form, action) {
130 //返回结果后触发保存事件
131 win.fireEvent('afterSave', win, win.md, true);
132 },
133 failure: function(form, action) {
134 //返回结果后触发保存事件
135 win.fireEvent('afterSave', win, win.md, true);
136
137 if (ac tion.failureType == 'server') {
138 obj = Ext.util.JSON.decode(action.response.responseText);
139 Ext.Msg.alert('更新失败!', obj.errors.reason);
140 } else {
141 Ext.Msg.alert('警告!', '服务不可用 : ' + action.response.responseText);
142 }
143
144 form.reset();
145 }
146 });
147 }
148 });
版权与免责声明
1、本站所发布的文章仅供技术交流参考,本站不主张将其做为决策的依据,浏览者可自愿选择采信与否,本站不对因采信这些信息所产生的任何问题负责。
2、本站部分文章来源于网络,其版权为原权利人所有。由于来源之故,有的文章未能获得作者姓名,署“未知”或“佚名”。对于这些文章,有知悉作者姓名的请告知本站,以便及时署名。如果作者要求删除,我们将予以删除。除此之外本站不再承担其它责任。
3、本站部分文章来源于本站原创,本站拥有所有权利。
4、如对本站发布的信息有异议,请联系我们,经本站确认后,将在三个工作日内做出修改或删除处理。
请参阅权责声明!