2

I have a list with handler on list item disclose, when the user click on an item I'm pushing a form view with the next code:

list.up('navigationview').push({
xtype: 'xEditAddFormPanel',
title: 'Edit task',
data: record.getData()
});

In the first click it's working and the navigation display the xEditAddFormPanel..

But then, after click on the back button (and return to the list screen) and then press again on list item (what triggers the above code again) - now nothing happens.

How do I display the form screen again?

kamaci
  • 72,915
  • 69
  • 228
  • 366
Oriel
  • 73
  • 1
  • 6

2 Answers2

1

I had the same problem and the reason was that the listener(s) is(are) lost the second time that you push a view into the navigator. Why? Because every time that you push a view into the Navigator the old view is destroyed, taking with it all listeners to the grave...

To get around this problem I binded the events manually whenever I create a new view that I wanted pushed:

onXButtonTap: function () {
    var view = Ext.create('MyApp.view.XEntryView');
    //Bind the events you need manually every time you push.
    view.on('myEvent', this.onSubmitNewX);
    this.getXMainView().push(view);
}
Mat Zero
  • 386
  • 3
  • 9
0

Often in Sencha, you have to manually destroy components. You may need to do something like this:

var formPanel = Ext.create('YourApp.view.EditAddFormPanel', {
    title: 'Edit task',
    data: record.getData()
});

formPanel.onAfter('erased', function(){
    this.destroy();
}, this);

list.up('navigationview').push(formPanel);
bjudson
  • 4,073
  • 3
  • 29
  • 46
  • When I destroy and then try to create and re-add I get the following error when I use the push function "Uncaught TypeError: Cannot call method 'detach' of null", what do you think? – Oriel Jan 05 '13 at 09:52
  • Do you have `var formPanel = ...` or just `formPanel = ...` like I originally put above (now updated)? If the latter, try with `var` so it is scoped properly. – bjudson Jan 05 '13 at 15:03