Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Some views do not get removed #190

Closed
mduman opened this Issue · 7 comments

3 participants

@mduman
  // If this is an array of items remove items that are not marked to
  // keep.
  if (_.isArray(manager.parent.views[manager.selector])) {
    // Remove directly from the Array reference.
    return manager.parent.getView(function(view, i) {
      // If the managers match, splice off this View.
      if (view.__manager__ === manager) {
        manager.parent.views[manager.selector].splice(i, 1);
      }
    });
  }

İ am not at my pc. The above code might not ( and in my site did not) remove corrrect views. İ may describe further in 3 days but i think you can see why.

Sorry for the short message. Best wishes.

@tbranyen
Owner

I can't see why. Please submit more details on the situation and reopen.

@tbranyen tbranyen closed this
@mduman

Suppose in "beforerender" function İ insert subviews with 2 different selectors.

This.insertview("thead", new view())
This.insertview("tbody", new view())

And suppose later i want to replace the second one. When I do this, the code I sent in the first message is executed.

In that code,
With manager.parent.getview you iterate both of the thead and tbody views, thus here "i" is the index of tbody view among all views (i=1).

Then you try to splice manager.parent.vıews["tbody"] array with index "1". But in this array the index of that view is 0.

So old view cannot be found and removed. Is it clear now? Sorry I can't verbally explain better. If it is not still clear enough, as I said I can send some code when I get access to my computer.

@drewzboto

Here's a test case that duplicates the issue:
#192

@drewzboto

Explanation from @mduman is correct. this occurs mainly when there are several child views, a mix of single views via setView and list views via insertView. the code is currently flattening all the views, thus we get the wrong splice index depending the order of the views when flattened.

oddly enough, only happens on one render after insert, and then it fixes itself. haven't quite dug into why that is just yet.

@tbranyen
Owner

Aha, thanks for the failing test and the excellent follow up @mduman thanks guys I'll get this patched tonight.

@tbranyen tbranyen reopened this
@mduman

Hello, thank you @drewzboto for your interest and making the case clear and thank you @tbranyen for the excellent library. Happy for smallest contribution if it counts at all :)

@tbranyen tbranyen closed this in cfce2ed
@drewzboto

awesome thanks guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.