-1

I am using Ext.util.StoreHolder mixin in my extjs 5.1 view.I found problem with Ext.destroy() method which throws error while destroying view having bindable mixin Ext.util.StoreHolder. I can not destroy that view, it giving me error

Uncaught TypeError: binding.destroy is not a function

at Ext.define.privates.removeBindings

My view is using mixin:

mixins: {
    bindable: 'Ext.util.StoreHolder'
},

Is there any problem with Ext.util.StoreHolder mixin? Why can't I destroy that view?

Edit -> , please find my code

Ext.define('MyApp.view.ux.CustomPagingBar', {
    extend: 'Ext.toolbar.Toolbar',
    alias : 'widget.custompagingbar',
    mixins: {
        bindable: 'Ext.util.StoreHolder'
    }
});

Error stack

Find Fiddle here Grid with Paging bar destroy issue

Abhijit Muke
  • 1,194
  • 3
  • 16
  • 41

2 Answers2

2

Make sure that you are unbinding the store when destroy is called on the view.

I think this should work.

Ext.define('MyApp.view.ux.CustomPagingBar' ,{
   extend: 'Ext.toolbar.Toolbar',
   alias : 'widget.custompagingbar',
   mixins: {
      bindable: 'Ext.util.StoreHolder'
  },

  // other code

  onDestroy: function(){
      var me = this;
        me.bindStore(null);
        // some other custom code if you want
        me.callParent();
    }


});

    // me.bindStore(null); this will unbind the store from the view before it is destroyed
Yellen
  • 1,785
  • 16
  • 35
  • You've onDestroy defined inside your CustomPagingBar? – Yellen Jun 05 '15 at 13:29
  • 1
    http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.Component-method-destroy – Yellen Jun 05 '15 at 13:29
  • no I don't have any onDestroy inside CustomPagingBar..I try your updated answer but still getting same problem `binding.destroy is not a function` – Abhijit Muke Jun 05 '15 at 13:31
  • Can you test in Chrome and enable pause on exception and check which binding is causing it? – Yellen Jun 05 '15 at 13:33
  • @Yellen...I try your answer to add onDestroy inside CustomPaginBar...still having same issue....`binding.destroy is not a function`. After debugging more it show me location where the error get thrown..`removeBindings() method from Ext.mixin.Bindable` – Abhijit Muke Jun 08 '15 at 12:09
  • @AbhijitMuke - I cannot say much unless I see much more of the code. – Yellen Jun 09 '15 at 13:13
  • @Yellen....I think you can help me...can we discuss more in chat http://chat.stackoverflow.com/rooms/80061/uncaught-typeerror-binding-destroy-is-not-a-function-in-extjs-5 – Abhijit Muke Jun 09 '15 at 13:26
  • 1
    @AbhijitMuke - You should post it in Sencha forum as well. – Yellen Jun 09 '15 at 13:31
  • @Yellen I got exact same problem because of a store binding: `items: [ { xtype: 'infocard', bind: { store: '{infoStore}' },`. I've replaced `onDestroy` method you gave on the panel which I'm using the `bind` config and placed it as listener but both way did not work. Still says: `binding.destroy() property not defined`. How can I over come? – Nuri Engin Feb 26 '18 at 11:44
  • I'm developing sencha's admindashboard and error raises during closing view on `Tab`. Probably view's `destroy` method and binding's are messing up. – Nuri Engin Feb 26 '18 at 11:47
  • @NuriEngin which extjs version are you using? – Yellen Feb 28 '18 at 10:10
  • @Yellen I'm using 6.5.3 – Nuri Engin Feb 28 '18 at 10:12
0

In Ext JS 5, Ext.mixin.Bindable has a new config--"bind"-- which allows bind descriptors to be defined on components.

In my component's "bind" method is overwriting this, and so the binding cleanup process is trying to destroy a binding, but doesn't have the proper configuration for it.

Commenting "bind" method prevent the destroy issue.

Abhijit Muke
  • 1,194
  • 3
  • 16
  • 41