Travis J
Travis J

Reputation: 82277

What approach should I use to do client side filtering?

I am making the front end of a asp.net mvc3 web application. A controller action sends a database driven list to a view model which then populates a series of divs. I have a filtering section above the div list. I am not sure which approach to take to implement the filter. I have considered rolling my own (I always keep this option on the table), using jQuery's .filter(), or finding some JavaScript functionality to use.

What is the standard way to filter client side with JavaScript (or a js derived library)?

EDIT

For gdoron's lack of context:

js

var gdoronArray = [];
for(var i = 0; i < 10000; i++){
 gdoronArray.push("text" + i + " " + (i*10));
}

Is there a standard library to pull only the items in gdoronArray which contain "ext5" or is this just a roll your own situation?

Upvotes: 1

Views: 808

Answers (1)

Esailija
Esailija

Reputation: 140220

gdoronArray.filter( function(v){
    return !!~v.indexOf("ext5");
});

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter

Upvotes: 2

Related Questions