首页 > 网站 > WEB开发 > 正文

解决easy ui两次请求服务器的问题

2024-04-27 14:17:28
字体:
来源:转载
供稿:网友

解决easy ui两次请求服务器的问题

目前该问题已经在1.4.1版本中解决了

本文引用自:http://www.cnblogs.com/Reaver/p/4056770.html,原文博主:flyreaver

我在使用过程中遇到了easy ui1.4版本的一个问题,使用datagrid的时候当请求数据为0条时,会重新请求一次后台。上面这位兄弟帮我解决了这个问题,表示感谢。

为了防止原文丢失,作此备份:

easyui datagrid 1.4 当total为0时,请求两次url问题

框架问题:需要在easyui文件后加修补补丁

  1 /**  2 * The Patch for jQuery EasyUI 1.4  3 */  4 (function($){  5     var plugin = $.fn._size;  6     $.fn._size = function(options, parent){  7         if (typeof options != 'string'){  8             return this.each(function(){  9                 parent = parent || $(this).parent(); 10                 if (parent.length){ 11                     plugin.call($(this), options, parent); 12                 } 13             }); 14         } else if (options == 'unfit'){ 15             return this.each(function(){ 16                 var p = $(this).parent(); 17                 if (p.length){ 18                     plugin.call($(this), options, parent); 19                 } 20             }); 21         } else { 22             return plugin.call(this, options, parent); 23         } 24     }; 25 })(jQuery); 26 (function($){ 27  $.map(['validatebox','textbox','filebox','searchbox', 28             'combo','combobox','combogrid','combotree', 29             'datebox','datetimebox','numberbox', 30             'spinner','numberspinner','timespinner','datetimespinner'], function(plugin){ 31         if ($.fn[plugin]){ 32             if ($.fn[plugin].defaults.events){ 33                 $.fn[plugin].defaults.events.click = function(e){ 34                     if (!$(e.data.target).is(':focus')){ 35                         $(e.data.target).trigger('focus'); 36                     } 37                 }; 38             } 39         } 40     }); 41     $.fn.combogrid.defaults.height = 22; 42  $(function(){ 43         $(document).bind('mousewheel.combo', function(e){ 44             $(e.target).trigger('mousedown.combo'); 45         }); 46     }); 47 })(jQuery); 48 (function($){ 49  $.extend($.fn.form.methods, { 50      clear: function(jq){ 51          return jq.each(function(){ 52              var target = this; 53              $('input,select,textarea', target).each(function(){ 54                     var t = this.type, tag = this.tagName.toLowerCase(); 55                     if (t == 'text' || t == 'hidden' || t == 'passWord' || tag == 'textarea'){ 56                         this.value = ''; 57                     } else if (t == 'file'){ 58                         var file = $(this); 59                         if (!file.hasClass('textbox-value')){ 60                             var newfile = file.clone().val(''); 61                             newfile.insertAfter(file); 62                             if (file.data('validatebox')){ 63                                 file.validatebox('destroy'); 64                                 newfile.validatebox(); 65                             } else { 66                                 file.remove(); 67                             } 68                         } 69                     } else if (t == 'checkbox' || t == 'radio'){ 70                         this.checked = false; 71                     } else if (tag == 'select'){ 72                         this.selectedIndex = -1; 73                     } 74                 }); 75                 var t = $(target); 76              var plugins = ['textbox','combo','combobox','combotree','combogrid','slider']; 77              for(var i=0; i<plugins.length; i++){ 78                  var plugin = plugins[i]; 79                  var r = t.find('.'+plugin+'-f'); 80                  if (r.length && r[plugin]){ 81                      r[plugin]('clear'); 82                  } 83              } 84              $(target).form('validate'); 85             }); 86         } 87     }); 88 })(jQuery); 89 (function($){ 90  function setSize(target, param){ 91      var opts = $.data(target, 'linkbutton').options; 92         if (param){ 93             $.extend(opts, param); 94         } 95         if (opts.width || opts.height || opts.fit){ 96             var btn = $(target); 97             var parent = btn.parent(); 98             var isVisible = btn.is(':visible'); 99             if (!isVisible){100                 var spacer = $('<div style="display:none"></div>').insertBefore(target);101                 var style = {102                     position: btn.CSS('position'),103                     display: btn.css('display'),104                     left: btn.css('left')105                 };106                 btn.appendTo('body');107                 btn.css({108                     position:'absolute',109                     display:'inline-block',110                     left:-20000111                 });112             }113             btn._size(opts, parent);114             var left = btn.find('.l-btn-left');115             left.css('margin-top', 0);116             left.css('margin-top', parseInt((btn.height()-left.height())/2)+'px');117             if (!isVisible){118                 btn.insertAfter(spacer);119                 btn.css(style);120                 spacer.remove();121             }122         }123     }124     var plugin = $.fn.linkbutton;125  $.fn.linkbutton = function(options, param){126         if (typeof options != 'string'){127             return this.each(function(){128                 plugin.call($(this), options, param);129                 setSize(this);130             });131         } else {132             return plugin.call(this, options, param);133         }134     };135     $.fn.linkbutton.methods = plugin.methods;136  $.fn.linkbutton.defaults = plugin.defaults;137     $.fn.linkbutton.parSEOptions = plugin.parseOptions;138  $.extend($.fn.linkbutton.methods, {139      resize: function(jq, param){140          return jq.each(function(){141              setSize(this, param);142          });143      }144  });145 })(jQuery);146 (function($){147     var plugin = $.fn.dialog;148     $.fn.dialog = function(options, param){149         var result = plugin.call(this, options, param);150         if (typeof options != 'string'){151             this.each(function(){152                 var opts = $(this).panel('options');153                 if (isNaN(parseInt(opts.height))){154                     $(this).css('height', '');155                 }156                 var onResize = opts.onResize;157                 opts.onResize = function(w, h){158                     onResize.call(this, w, h);159                     if (isNaN(parseInt(opts.height))){160                         $(this).css('height', '');161                     }162                     var shadow = $.data(this, 'window').shadow;163                     if (shadow){164                         var cc = $(this).panel('panel');165                         shadow.css({166                             width: cc._outerWidth(),167                             height: cc._outerHeight()168                         });169                     }170                 };171                 if (opts.closed){172                     var pp = $(this).panel('panel');173                     pp.show();174                     $(this).panel('resize');175                     pp.hide();176                 }177             });178         }179         return result;180     };181     $.fn.dialog.methods = plugin.methods;182     $.fn.dialog.parseOptions = plugin.parseOptions;183     $.fn.dialog.defaults = plugin.defaults;184 })(jQuery);185 (function($){186  function createTab(container, pp, options) {187      var state = $.data(container, 'tabs');188         options = options || {};189         // create panel190         pp.panel({191             border: false,192             noheader: true,193             closed: true,194             doSize: false,195             iconCls: (options.icon ? options.icon : undefined)196         });197         var opts = pp.panel('options');198         $.extend(opts, options, {199          onLoad: function(){200              if (options.onLoad){201                  options.onLoad.call(this, arguments);202              }203              state.options.onLoad.call(conta
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表