javascript - Passing variable into Backbone.where -


i want form collection json based on obtained value , backbone's where seemed perfect tool, looks doesn't accept variables. possible achieve sort of functionality using of backbone, lodash or underscore methods?

### collection instantiated above  app.vent.on 'event', (obtained_value) ->   desired_models = collection.where(attribute: obtained_value)   console.log desired_models  ### outputs empty array >[] 

it work when pass key: value directly, need form collection dynamically. maybe i've taken false route , solution in direction?

i'm assuming goal vary attribute you're searching for, since if value varied, object literals should work fine.

you can it, not object literal inline. here's how in javascript:

app.vent.on('event', function (obtainedvalue) {     var finder = {};     finder[attribute] = obtainedvalue;     desiredmodels = collection.where(finder);     console.log(desiredmodels); }); 

Comments