⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 action.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
 * Ext JS Library 3.0 Pre-alpha
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.form.Action * <p>The subclasses of this class provide actions to perform upon {@link Ext.form.BasicForm Form}s.</p> * <p>Instances of this class are only created by a {@link Ext.form.BasicForm Form} when * the Form needs to perform an action such as submit or load. The Configuration options * listed for this class are set through the Form's action methods: {@link Ext.form.BasicForm#submit submit}, * {@link Ext.form.BasicForm#load load} and {@link Ext.form.BasicForm#doAction doAction}</p> * <p>The instance of Action which performed the action is passed to the success * and failure callbacks of the Form's action methods ({@link Ext.form.BasicForm#submit submit}, * {@link Ext.form.BasicForm#load load} and {@link Ext.form.BasicForm#doAction doAction}), * and to the {@link Ext.form.BasicForm#actioncomplete actioncomplete} and * {@link Ext.form.BasicForm#actionfailed actionfailed} event handlers.</p> */Ext.form.Action = function(form, options){    this.form = form;    this.options = options || {};};/** * Failure type returned when client side validation of the Form fails * thus aborting a submit action. Client side validation is performed unless * {@link #clientValidation} is explicitly set to <tt>false</tt>. * @type {String} * @static */Ext.form.Action.CLIENT_INVALID = 'client';/** * <p>Failure type returned when server side processing fails and the {@link #result}'s * <tt style="font-weight:bold">success</tt> property is set to <tt>false</tt>.</p> * <p>In the case of a form submission, field-specific error messages may be returned in the * {@link #result}'s <tt style="font-weight:bold">errors</tt> property.</p> * @type {String} * @static */Ext.form.Action.SERVER_INVALID = 'server';/** * Failure type returned when a communication error happens when attempting * to send a request to the remote server. The {@link #response} may be examined to * provide further information. * @type {String} * @static */Ext.form.Action.CONNECT_FAILURE = 'connect';/** * Failure type returned when the response's <tt style="font-weight:bold">success</tt> * property is set to <tt>false</tt>, or no field values are returned in the response's * <tt style="font-weight:bold">data</tt> property. * @type {String} * @static */Ext.form.Action.LOAD_FAILURE = 'load';Ext.form.Action.prototype = {/** * @cfg {String} url The URL that the Action is to invoke. *//** * @cfg {Boolean} reset When set to <tt><b>true</b></tt>, causes the Form to be * {@link Ext.form.BasicForm.reset reset} on Action success. If specified, this happens * <b>before</b> the {@link #success} callback is called and before the Form's * {@link Ext.form.BasicForm.actioncomplete actioncomplete} event fires. *//** * @cfg {String} method The HTTP method to use to access the requested URL. Defaults to the * {@link Ext.form.BasicForm}'s method, or if that is not specified, the underlying DOM form's method. *//** * @cfg {Mixed} params <p>Extra parameter values to pass. These are added to the Form's * {@link Ext.form.BasicForm#baseParams} and passed to the specified URL along with the Form's * input fields.</p> * <p>Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode}.</p> *//** * @cfg {Number} timeout The number of seconds to wait for a server response before * failing with the {@link #failureType} as {@link #Action.CONNECT_FAILURE}. If not specified, * defaults to the configured <tt>{@link Ext.form.BasicForm#timeout timeout}</tt> of the * {@link Ext.form.BasicForm form}. *//** * @cfg {Function} success The function to call when a valid success return packet is recieved. * The function is passed the following parameters:<ul class="mdetail-params"> * <li><b>form</b> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li> * <li><b>action</b> : Ext.form.Action<div class="sub-desc">The Action class. The {@link #result} * property of this object may be examined to perform custom postprocessing.</div></li> * </ul> *//** * @cfg {Function} failure The function to call when a failure packet was recieved, or when an * error ocurred in the Ajax communication. * The function is passed the following parameters:<ul class="mdetail-params"> * <li><b>form</b> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li> * <li><b>action</b> : Ext.form.Action<div class="sub-desc">The Action class. If an Ajax * error ocurred, the failure type will be in {@link #failureType}. The {@link #result} * property of this object may be examined to perform custom postprocessing.</div></li> * </ul> *//** * @cfg {Object} scope The scope in which to call the callback functions (The <tt>this</tt> reference * for the callback functions). *//** * @cfg {String} waitMsg The message to be displayed by a call to {@link Ext.MessageBox#wait} * during the time the action is being processed. *//** * @cfg {String} waitTitle The title to be displayed by a call to {@link Ext.MessageBox#wait} * during the time the action is being processed. *//** * The type of action this Action instance performs. * Currently only "submit" and "load" are supported. * @type {String} */    type : 'default',/** * The type of failure detected will be one of these: {@link #CLIENT_INVALID}, * {@link #SERVER_INVALID}, {@link #CONNECT_FAILURE}, or {@link #LOAD_FAILURE}.  Usage: * <pre><code>var fp = new Ext.form.FormPanel({...buttons: [{    text: 'Save',    formBind: true,    handler: function(){        if(fp.getForm().isValid()){            fp.getForm().submit({                url: 'form-submit.php',                waitMsg: 'Submitting your data...',                success: function(form, action){                    // server responded with success = true                    var result = action.{@link #result};                },                failure: function(form, action){                    if (action.{@link #failureType} === Ext.form.Action.{@link #CONNECT_FAILURE}) {                        Ext.Msg.alert('Error',                            'Status:'+action.{@link #response}.status+': '+                            action.{@link #response}.statusText);                    }                    if (action.failureType === Ext.form.Action.{@link #SERVER_INVALID}){                        // server responded with success = false                        Ext.Msg.alert('Invalid', action.{@link #result}.errormsg);                    }                }            });        }    }},{    text: 'Reset',    handler: function(){        fp.getForm().reset();    }}] * </code></pre> * @property failureType * @type {String} */ /** * The XMLHttpRequest object used to perform the action. * @property response * @type {Object} */ /** * The decoded response object containing a boolean <tt style="font-weight:bold">success</tt> property and * other, action-specific properties. * @property result * @type {Object} */    // interface method    run : function(options){    },    // interface method    success : function(response){    },    // interface method    handleResponse : function(response){    },    // default connection failure    failure : function(response){        this.response = response;        this.failureType = Ext.form.Action.CONNECT_FAILURE;        this.form.afterAction(this, false);    },    // private    processResponse : function(response){        this.response = response;        if(!response.responseText){            return true;        }        this.result = this.handleResponse(response);        return this.result;    },    // utility functions used internally    getUrl : function(appendParams){        var url = this.options.url || this.form.url || this.form.el.dom.action;        if(appendParams){            var p = this.getParams();            if(p){                url += (url.indexOf('?') != -1 ? '&' : '?') + p;            }        }        return url;    },    // private    getMethod : function(){        return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();    },    // private

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -