Ajax::prototype 源码解读

2019-06-03 08:36:20刘景俊

    } 

    this.request = new Ajax.Request(url, this.options); 

    if (!this.options.asynchronous) 
      this.updateContent(); 
  }, 

  updateContent: function() { 
    if (this.options.insertion) { 
      new this.options.insertion(this.container, 
        this.request.transport.responseText); 
    } else { 
      this.container.innerHTML = this.request.transport.responseText; 
    } 

    if (this.onComplete) { 
      setTimeout((function() {this.onComplete(this.request)}).bind(this), 10); 
    } 
  } 
});
Ajax::prototype 源码解读 之 prototype.js 三[转载] 
/** 
 * 针对 页面元素对象 的工具类,提供一些简单静态方法 
 */ 
var Field = { 
  /** 
   * 清除参数引用对象的值 
   */ 
  clear: function() { 
    for (var i = 0; i < arguments.length; i++) 
      $(arguments[i]).value = ''; 
  }, 

  /** 
   * 使参数引用对象获取焦点 
   */ 
  focus: function(element) { 
    $(element).focus(); 
  }, 

  /** 
   * 判断参数引用对象值是否为空,如为空,返回false, 反之true 
   */ 
  present: function() { 
    for (var i = 0; i < arguments.length; i++) 
      if ($(arguments[i]).value == '') return false; 
    return true; 
  }, 

  /** 
   * 使选中参数引用对象 
   */ 
  select: function(element) { 
    $(element).select(); 
  }, 

  /** 
   * 使参数引用对象处于可编辑状态 
   */ 
  activate: function(element) { 
    $(element).focus();