1
votes

I have a marionette ItemView, which creates some children views. These children views are using jQuery UI's draggable function on their elements. I instantiate the draggable in the onRender of the child view.

When I call close on the parent view, in it's onClose function, I call close on the children views. In the onClose if the child views, I am calling .draggable("destroy"). My problem is, I get the following error: cannot call methods on draggable prior to initialization; attempted to call method 'destroy'

I am using backbone babysitter to manage my children views.

Any ideas? Is there a different way I should manage closing children views?

1

1 Answers

0
votes

the onClose method get fired after the Close method of the view. the close method of the view does the following per the documentation. https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md#view-close

  • unbind all listenTo events
  • unbind all custom view events
  • unbind all DOM events
  • remove this.el from the DOM
  • call an onBeforeClose event on the view, if one is provided
  • call an onClose event on the view, if one is provided

so if the clean up that this method does is not enough for your scenario and you still need to call destroy, try doing it in the onBeforeClose method, this will me called before the close method.