即時通訊使用當前jQuery UI的滑塊與一個範圍: http://jqueryui.com/slider/#range如何獲得價格x和y之間的條目?
和underscore.js http://underscorejs.org/
所以香港專業教育學院一個最小和一個最大我發送,在用戶停止滑動至功能:
currentSlide:function(){
$('#slider').slider({
range: true,
min: min,
max: max,
values: [ vmin, vmax ],
stop:$.proxy(this.afterSlide,this)
});
},
afterSlide:function(event, ui) {
console.log(ui.values[0]);
},
在afterSlide功能我得到正確的最小/最大
,但我不知道如何使用underscore.js獲得具有本分和最終由最高價格開始的所有條目。
Examplearray:
var sample = {
"response": {
"things": [{
"index": 0,
"price": "10"
},{
"index": 1,
"price": "15"
},{
"index": 2,
"price": "60"
},{
"index": 3,
"price": "10"
},{
"index": 4,
"price": "100"
}
]
}
};
使用滑塊我有最小值/最大值[12,61],所以我希望看到所有條目僅與12之間的價格開始,61 $
var result = _.find(sample.response.things, min/max);??
IM後
我不明白_.range()函數正確使用它,我需要如何,或與.where/ .find()函數創建正確的語句。
的可能重複(http://stackoverflow.com/questions/11697702/how-to-use-underscore-js -filter-with-an-object) – Phrogz 2013-02-11 17:19:04
nope。它不是dublicate,因爲需要一個比較來獲得範圍之間的所有條目而不是一個鍵/值對 – JohnDoo 2013-02-11 17:21:58