javascript根据它对地图进行排序';s属性和返回映射
我正在尝试对过滤器中的贴图进行排序并返回贴图javascript根据它对地图进行排序';s属性和返回映射,javascript,canjs,Javascript,Canjs,我正在尝试对过滤器中的贴图进行排序并返回贴图 var sort = this.attr('component').attr('sort'); if (sort == 'Price Descending') { return this.attr('%root.products').filter(function(product) { // How can I sort 'product' here before returning?
var sort = this.attr('component').attr('sort');
if (sort == 'Price Descending')
{
return this.attr('%root.products').filter(function(product) {
// How can I sort 'product' here before returning?
return (product.attr(product.attr('active') !== 'f';
});
}
如上所述,在返回和比较产品回调变量之前,如何对其进行排序
任何帮助都将不胜感激。这基本上是一个映射,它被过滤到一个数组,这是一个映射,它返回一个已解决的承诺
prodcut.attr('price')
包含价格,我需要在返回itI之前对其进行向下排序。我看不出attr()
如何返回字符串以外的任何内容。如果this
是jQuery对象,attr()
返回一个字符串this
是一个映射,即视图模型,由属性范围内的var self=this
接收。这与jQuery无关,正如OP标题和标记中所指出的