EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: chkaufmann on February 17, 2014, 01:42:39 AM



Title: Global loader function
Post by: chkaufmann 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


Title: Re: Global loader function
Post by: stworthy 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>