Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
属性の1つ(region_list)が文字列の配列であるモデルのバックボーンコレクションがあります。region_listに特定の文字列が含まれているすべてのモデルを見つけるにはどうすればよいですか?
collection.filter(function(model){ return ( _.indexOf(model.get('region_list'), 'specific_string') >= 0 ); });
アンダースコアのfilterメソッドとindexOfregion_listメソッドを使用して、配列に値が含まれているコレクション内のすべてのモデルをフィルター処理しますspecific_string。
region_list
specific_string
この.filter()呼び出しからの戻り値は、モデルの配列になります。