emposha / FCBKcomplete

Jquery facebook like(fancy) multi-select
http://www.emposha.com
383 stars 115 forks source link

Caching doesn't work? #64

Closed dkvdm closed 12 years ago

dkvdm commented 13 years ago

It appears that even though I have caching turned on, I see it make a server GET request everytime I type in the form of /gettags?tag=testsear.

How can I make sure it's not trying to a get a new json doc everytime I type?

I use the following code:

$(document).ready(function(){
    $("#tagselect").fcbkcomplete({
        json_url: "/gettags",
        cache: true,
        filter_case: false,
        filter_hide: true,
        firstselected: true,
        filter_selected: true,
        addontab: true,
        maxitems: 5,
        delay: 300,
        newel: true,
    });
});

Thanks!

Dennis

emposha commented 13 years ago

Cache work for already fetched key => values pairs, that mean that when you start type "test" for each character ('t", "te", "tes", "test") cache instance created so if you will decide to delete last char for example "tes" the result will be fetched from cache. In your case you can increase delay time and this will decrease number of request to your server.

dkvdm commented 13 years ago

As in the code example, I currently have set delay: 300, which would mean 5 minutes...unless a different unit is being used. Is the delay option in seconds or milliseconds?

I've tried to use 10000 (10 seconds), but then when I type it only starts to retrieve tags after 10 seconds. Basically I just want it to retrieve the first time, and do it again if necessary in 5 minutes.

Thanks, Dennis

emposha commented 13 years ago

It`s in milliseconds. In your case you can preset values to "select" element on html page render, and then set delay to 5 min (delay = 300000)

dkvdm commented 13 years ago

Hey emposha, how would I go and preset those values on document ready? I've been trying for the last 30 minutes but have been unable to do so.

Many thanks, Dennis

dkvdm commented 13 years ago

Still haven't been able to do so, I'm trying to invoke the retrieval of the list on doc ready, but that didn't work. The next thing I tried was to create an event trigger that would set the initial 300ms delay to 300000ms after the first run. Both unfortunately didn't work. How can I make sure it starts the sequence by retrieving tags first, and then waiting 5 minutes to try again?

Thanks again, Dennis

emposha commented 13 years ago

Try render your html page with needed values and I mean that when you apply fcbkcompelete your select should be look like this <select> <option/>1</option> <option/>2</option> <option/>3</option> .... </select> so 1, 2, 3 will be added to list automatically at fcbkcomplete initialization