extjs 4 MVCアプリケーション:未定義のエラーをフォーム
-
27-10-2019 - |
質問
私はextjs 4を初めて使用しており、MVCスタイルで簡単なアプリケーションを実装しようとしています。ドキュメントは本当に優れており、これはフォームパッケージガイドで説明されているトピックの1つですが、私の場合は機能しないようです。
アプリは基本的に記事を作成、編集、削除できます。作成と編集はポップアップウィンドウにあります。ポップアップウィンドウには、テキストフィールドとHTML-Editorを備えたフォームが含まれています。以下のリンクをクリックしてください。これは、「ウィンドウ」の送信ボタンをクリックすると、Google Chromeコンソールのエラーです。
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');
},
私が何か間違ったことをしている場合に備えて、私を正しい方向に向けてください。前もって感謝します。
解決
ドキュメントを確認してください getRecord():
LoadRecordを介してロードされた最後のext.data.modelインスタンスを返します
したがって、レコードを読み込んでいないことは明らかです。そして、あなたはあなたのエラーをさらに取得しています。
所属していません StackOverflow