D
D
Danil2015-10-12 16:54:58
JavaScript
Danil, 2015-10-12 16:54:58

How to remove everything from $el in Backbone View?

There is a view, and there, a collection of elements. I do view.remove(), the DOM is updated there, everything disappears, but when I look in view.$el, the elements remain there. How can I remove them from there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
malroc, 2015-10-12
@Veneomin

view.$el.empty()
But it's not at all clear why you do this. If you don’t use the view anywhere after that and don’t store references to it, then the garbage collector will clean everything up later. If you use it, then when redrawing the contents of $el will be updated, and the old one will again go to the garbage collector.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question