onKeyup没有收到过去的最后一封信

时间:2016-03-02 18:19:25

标签: javascript jquery filter shuffle onkeyup

我正在使用位于此处的shufflejs: http://vestride.github.io/Shuffle/ 只有在用户快速输入时,我才能抓住最后一个字母。例: 用户类型" pug" "联想电脑"," Mac电脑"," Pug Dog"和"紫色椅子"因为他们都有" pu"在里面。此外,如果我按退格3次删除单词" pug"在搜索框中,它不会默认为原始位置。我必须打4次,即使搜索很清楚。

如果用户输入的速度很慢,则不会发生这种情况,一切都按预期工作。 我尝试过onkeydown,onkeypress,onkeychange和oninput,但似乎没有什么能解决它。

请让我知道我做错了什么。我确定我错过了一些小细节,但我无法理解。任何帮助是极大的赞赏。

HTML

abstract class PowerStat{
    final int numOfComponent = UserProperty.numOfComponent;
    final int windowSize = 8;

    CircularFifoQueue<ArrayList<Double>> movingEnergy;
    CircularFifoQueue<Double> movingStartTimes;
    CircularFifoQueue<Double> movingEndTimes;

    private double [] maxPower = new double[numOfComponent];
    private double [] minPower = new double[numOfComponent];

    public ArrayList<Double> intervalEnergy = new ArrayList<Double>(numOfComponent);

    private ArrayList<UsageNode> usageList = new ArrayList<UsageNode>();

    public PowerStat(){
        setUsageList(new ArrayList<UsageNode>());
        for (int i = 0; i < numOfComponent; i++) {
            intervalEnergy.add(0.0);
        }

        movingEnergy = new CircularFifoQueue<ArrayList<Double>>(windowSize);
        movingStartTimes = new CircularFifoQueue<Double>(windowSize);
        movingEndTimes = new CircularFifoQueue<Double>(windowSize);
    }
}

JS

<div class="col-md-4" data-groups="electronic" data-title="Lenovo Computer">
    <img src="image/lenovoLap.jpg" class="img-responsive" />
        <figcaption class="picture-item__title">Lenovo Computer</figcaption>
</div>
<div class="col-md-4" data-groups="electronic" data-title="Mac Computer">
    <img src="image/macBook.jpg" class="img-responsive" />
        <figcaption class="picture-item__title">Mac Computer</figcaption>
</div>
<div class="col-md-4" data-groups="pet" data-title="Pug Dog">
    <img src="image/pugDog.jpg" class="img-responsive" />
        <figcaption class="picture-item__title">Pug Dog</figcaption>
</div>
<div class="col-md-4" data-groups="furniture" data-title="Purple Chair">
    <img src="image/PurpleChair.jpg" class="img-responsive" />
        <figcaption class="picture-item__title">Purple Chair</figcaption>
</div>

0 个答案:

没有答案