すべてのフィールドが sencha touch の json ファイルから取得される動的フォームを作成するにはどうすればよいですか?
(「回答」から転送された追加の詳細)
私のjsonは次のようになります{
success: true,
data: [
{xtype: "textfield", title: "label1", name: "textfield1"},
{xtype: "emailfield", title: "label2", name: "textfield2"},
{xtype: "passwordfield", title: "label3", name: "textfield3"},
{xtype: "button", title: "button", name: "button"}
]
}
別のコントローラーとビューが必要です。私はこのような単一のコントローラーファイルでそれをしました
form = Ext.create('MyApp.view.MyDataView');
var test=this;
var ajax = Ext.Ajax.request({
url: 'contacts.json',
method: 'get',
success: function(response)
{
console.log(response);
response = Ext.JSON.decode(response.responseText);
this.hello=response;
console.log(response.data.length);
for (var i = 0; i < response.data.length; i++)
{
form.add({
xtype: response.data[i].xtype,
id:response.data[i].title,
action:response.data[i].title,
label: response.data[i].title,
name: response.data[i].name
});
}
console.log(form.getValues());
form.setLayout();
form.show(document.body);
Ext.Viewport.animateActiveItem(form,{type: 'flip', direction: 'right'});
}
utton タップイベントに関して私が直面している問題があり、複数のボタンがある場合、それらにイベントを与えることはまだできません....これに関して誰か助けてもらえますか..