DarkBandit0
New Member
I have run into some trouble with a piece of backbone code. The code below relates to a render function. I can retrieve all the models. My trouble arises when I try to use the "Collections.where" method at line marked number #1. As you can see, I have passed an object literal into the render function but for some reason I am unable to reference it within the customers.where method on line #1. When I give this method a literal number like 45 it works. Is there some way around this so I can pass the variable reference in?Thanks alot\[code\]render: function(options) { var that = this; if (options.id) { var customers = new Customers(); customers.fetch({ success: function (customers) { /* #1 --> */ var musketeers = customers.where({musketeerId: options.id}); console.log(musketeers.length) //doesn't work as options.id is failing on last line var template = _.template($('#customer-list-template').html(), { customers: customers.models }); that.$el.html(template); console.log(customers.models); } }); } else { var template = _.template($('#customer-list-template').html(), {}); that.$el.html(template); }}\[/code\]