简体   繁体   中英

Marionette CollectionView filter not working

I see questions about properly filtering a CollectionView. None of the prescriptions are working for me. I must not be getting the concept.

If I have a collection of models, and I want to show only those with an attribute "visible" set to "true", I should filter the collection in the CollectionView. I thought this was the right way to do that:

    var myCollectionView = new MyCollectionView ({
        collection: new FilteredCollection(UnfilteredCollection.where({ visible: 'true' }))                
    });

When I add 10 models to UnfilteredCollection, 5 with visible=false and 5 with visible=true, and show myCollectionView in a region, I should see 5 items. I'm getting none.

If I drop the filter and just show the UnfilteredCollection, I see all 10 items, so I know I'm wired right other than this filtered stuff.

Setting a VS breakpoint I can see the proper values in the collection's models - 5 visible=false and 5 visible=true.

What am I missing here?

{ visible: 'true' }

这使我认为您可能会不小心在true值周围添加引号,从而使它成为字符串,而您的模型中可能会有布尔值true/false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM