新しいフィールドをクリックして追加するフォームがあります。http://jsfiddle.net/Zb8DV/
ユーザーは自分の入力を追加して保存をクリックできます。
onsave イベントで状態を Cookie に保存したい。
次回彼がフォームに入力したときに、状態をロードし、最後にフォームに入力したときの値を入力してフィールドを生成したいと思います。
したがって、次のフォームを見ると、「フィールドを追加」をクリックすると新しいフィールドが生成されます。フィールドを追加して値を入力した後、状態を保存して次回ロードしたい...
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 500,
bodyPadding: 10,
title: 'Stateful',
stateful : true,
stateId : "MyFormState",
items: [{
xtype: 'button',
text: 'add field',
count: 0,
handler: function () {
this.count += 1;
var me = this;
this.up("form").add([{
"xtype": 'textfield',
name: 'field' + me.count,
fieldLabel: 'field ' + me.count
}]);
}
}, {
xtype: 'button',
margin : '10 10 10 100',
text: 'Save form state on click here',
handler : function(){alert("how do I load the panel with the state saved in cookie??")}
}],
});