jasonhinkle / phreeze

Phreeze Framework for PHP
http://phreeze.com/
GNU Lesser General Public License v2.1
377 stars 166 forks source link

Refresh #98

Open jenunifer opened 11 years ago

jenunifer commented 11 years ago

Hi Jason!

Thank you so much for all your help, thus far. I have been able to successfully get my application to function and add features as necessary! One issue I have come across is the refresh rate. I have changed the search box to use a live filtering, which filters as you type...however, it seems that when the app refreshes (~5 seconds) it does not keep the filter. Example:

OLD // initialize the search filter /* $('filter').live(function(obj){ page.fetchParams.filter = $('#filter').val(); page.fetchParams.page = 1; page.fetchHosts(page.fetchParams); }); */

NEW $('input.filter').live('keyup', function(e) { var rex = new RegExp($(this).val(), 'i'); $('.searchable tr').hide(); $('.searchable tr').filter(function() { return rex.test($(this).text()); }).show(); });

Where can I

A: slow down refresh time and/or B. Keep filter until its wiped.

Thanks!

jasonhinkle commented 11 years ago

Sorry for the long delay in response - crunch time at the day job! That setting is found in model.js

model.longPollDuration = 5;

You could change that to a longer duration, or change it to 0 if you don't want long polling at all. To really fix the issue what probably should happen with Phreeze is that it doesn't refresh if the filter box is active. I'm not sure the best way to determine if the user is actively typing in the filter box - perhaps keystrokes in that textarea or something. The code that controls the actual refresh part, though, is in your relevant app/tablename.js file and the code looks like this:

    if (model.longPollDuration > 0)
    {
        setInterval(function () {

            if (!page.dialogIsOpen)
            {
                page.fetchCustomers(page.fetchParams,true);
            }

        }, model.longPollDuration);
    }

If you notice there's already a condition where the polling won't refresh if the editor dialog is visible. So, it wouldn't be tough to add another condition there. The tough part is just figuring out whether the user is in mid-type. If anybody knows how to do this I'd be happy to take a pull request. I'll probably get to it eventually otherwise.

Thanks for letting me know!