简体   繁体   中英

How to set auto refresh for grocery crud?

I am using grocery crud library to show my database record and it is working perfectly. But how can I get real time record from database without refreshing the page. To do this I put a script in template file name is list_template.php in flexigrid theme.

setInterval(function(){ $('#crud_search').trigger('click'); },10000);

which is refreshing the record too but it is always showing me record from starting not the current page. The current page means if i am on page 3 it is showing page 1 as interval.

I had a similar problem with autoload and i solved doing this:

I just created a js file called refresh on assets/js/refresh, and added the following:

js file

var interval = null;

window.onload = function() {
    interval = setInterval(callFunc, 5000);    
};

function callFunc() {
       $("#ajax_refresh_and_loading").trigger("click");
}

Controller side

$jsfile = 'assets/bootstrap/js/refresh.js';
        $crud->set_js($jsfile);

I hope this is what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM