EasyUI Forum
May 21, 2024, 01:22:17 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: Global loader function  (Read 6662 times)
chkaufmann
Newbie
*
Posts: 15


View Profile Email
« on: February 17, 2014, 01:42:39 AM »

I want to override the loader function globally. What is the better way to do it?

Code:
  $('.easyui-treegrid').each( function() {
    $(this).treegrid({
      loader:function(param,success,error) {
        // my loader code
      }
    });
  });

or like this:

Code:
  $.fn.combobox.defaults.loader = function(param, success, error) {
    var opts = $(this).combobox('options');
    if (!opts.url) return false;
    bsSendRestRequest(opts.url, param, null, success);  // my own loader method
  };

I noticed, that for dynamic items, e.g. combobox in a propertygrid, only the second variant is working. But I don't know, if there is any tradeoff.
Or is there another way to do it?

cu Christian
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 17, 2014, 05:20:39 PM »

The code below overrides the default 'loader' for all combobox components.
Code:
<script>
$.fn.combobox.defaults.loader = function(param,success,error){
  //...
};
</script>

To override the 'loader' for a specified combobox component, try this:
Code:
<script>
$(function(){
$('#cc').combobox({
  loader: function(param,success,error){
    //..
  }
});
});
</script>
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!