私はExtJS4を初めて使用し、MVCスタイルで単純なアプリケーションを実装しようとしています。ドキュメントは本当に良いです、そしてこれはフォームパッケージガイドでカバーされたトピックの1つです、しかしそれは私の場合にはうまくいかないようです。
アプリは基本的に記事を作成、編集、削除することができます。作成と編集はポップアップウィンドウで行われます。ポップアップウィンドウには、テキストフィールドとhtml-editorを含むフォームが含まれています。下のリンクをクリックしてください。これは、「ウィンドウ」の送信ボタンをクリックしたときのGoogleChromeコンソールのエラーです。
http://www.freeimagehosting.net/mjig7
これが私がモデルを書いたコードです:
Ext.define('AM.model.Article', {
extend: 'Ext.data.Model',
fields: ['name', 'data'],
proxy: {
type: 'rest',
url: 'users/data',
reader: {
type: 'json',
root: 'myJaxBean',
successProperty: 'success'
},
writer: {
type: 'json'
}
}
});
意見:
Ext.define('AM.view.New', {
extend: 'Ext.window.Window',
alias : 'widget.new',
title : 'New Article',
autoShow: true,
fieldDefaults: {
labelAlign: 'top',
msgTarget: 'side'
},
layout: 'fit',
bodyStyle:'padding:5px 5px 0',
width: '70%',
height: '40%',
initComponent: function() {
this.items = [
{
xtype: 'form',
anchor: '99%',
items: [
{
xtype: 'textfield',
name : 'name',
fieldLabel: 'Article Name',
anchor: '99%'
},
{
xtype: 'htmleditor',
name : 'data',
fieldLabel: 'Article',
anchor: '99% -25'
}
],
buttons: [
{
text: 'Submit',
handler: function() {
var form = this.up('form').getForm(), // get the basic form
record = form.getRecord(); // get the underlying model instance
if (form.isValid()) { // make sure the form contains valid data before submitting
form.updateRecord(record); // update the record with the form data
record.save({ // save the record to the server
success: function(user) {
Ext.Msg.alert('Success', 'User saved successfully.')
},
failure: function(user) {
Ext.Msg.alert('Failure', 'Failed to save user.')
}
});
} else { // display error alert if the data is invalid
Ext.Msg.alert('Invalid Data', 'Please correct form errors.')
}
}
},
{
text: 'Cancel',
scope: this,
handler: this.close
}
]
}
],
this.callParent(arguments);
}
});
そして最後に、ウィンドウを表示するコントローラーのコード
コントローラ:
.....
'viewport > panel > panel > tbar button[action=newarticle]' :{
click: this.newArticle
},
....
newArticle: function(button){
var view = Ext.widget('new');
},
私が何か間違ったことをしている場合に備えて、私を正しい方向に向けてください。前もって感謝します。