EasyUI Forum
June 15, 2024, 06:15:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: prevent loadData unless specifically called  (Read 7057 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: February 25, 2013, 02:20:23 AM »

I believe that by default, when the page containing an easyui element is loaded into the browser, all of the elements will automatically make ajax calls to retrieve their data.

I have an application which instead of loading new html pages upon a menu click, it hides, shows a div on one single .html page to reveal the selected contents, but this means that when my page is loaded (refreshed) into the browser, every element will be make ajax calls which is not very efficient and not really what I want to do, as there are potentially a LOT of elements.

So is it possible to GLOBALLY prevent ALL elements from loading their data unless the loadData or reload command is specifically called ??

Right now, I have added a new attribute urx="somepage.php" to each input and then i copy the urx value to the element's url variable when the panel is selected and the parent div's style is changed from hidden to display, bu this is not very efficient.

Many Thanks




« Last Edit: February 25, 2013, 02:27:21 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 25, 2013, 06:25:37 AM »

Many components have 'onBeforeLoad' event, which can be used to determine if to load data. Here is the code shows how to prevent from loading data into datagrid at first time and call 'reload' method again to load data normally.
Code:
$('#dg').datagrid({
    onBefore:function(){
var opts = $(this).datagrid('options');
if (!opts.canLoad){
opts.canLoad = true;
return false;
}
    }
});

The loading behavior can also be applied to all the datagrid components.
Code:
$.fn.datagrid.defaults.onBeforeLoad = function(){
var opts = $(this).datagrid('options');
if (!opts.canLoad){
opts.canLoad = true;
return false;
}
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!