js 关于this引起的错误

来源:互联网 发布:类似于快刀的软件 编辑:程序博客网 时间:2024/06/01 10:14
        _savePayment: function () {            var _this = this;            //var params = $("#payment_partial input").serializeArray();            window.oscObserver.beforeUpdatePaymentMethod();            var params = $("#checkout_form").serializeArray();            params[params.length] = {'name': 'step', 'value': 'payment_method'};            this.queueProcess('save_payment',{                url: _this.options.saveStepUrl,                type: 'POST',                data: params,                //async : false,                beforeSend: function () {                    _this._loadWait('review_partial');                    if (_this.options.payment.loading_shipping_method)                        _this._loadWait('shipping_partial');                },                complete: function (response) {                    try {                        var responseObject = $.parseJSON(response.responseText);                    } catch (ex) {                        _this._removeWait();                        return false;                    }                    _this._updateHtml(responseObject);                    window.oscObserver.afterUpdatePaymentMethod(responseObject);                }            });        },





        _create: function () {            this._super();            var _this = this;            var isCheckExistEmail = $("input[name='billing[create_new_account]']").is(":checked") || $("#billing\\:email").hasClass('check-email-exists');            if (isCheckExistEmail) {                $("#billing\\:email").trigger('change');            }            $("input[name='billing[create_new_account]']").on('change', function () {                if ($(this).is(":checked")) {                    $("#billing\\:email").trigger('change');                }            });            $("#billing\\:email").bind('change', function () {                var isCheckExistEmail = $("input[name='billing[create_new_account]']").is(":checked") || $("#billing\\:email").hasClass('check-email-exists');                alert(isCheckExistEmail)                if (!isCheckExistEmail)                    return;                _this.queueProcess('check_email', {                    url: _this.options.billing.checkExistsUrl,                    type: 'POST',                    //async : false,                    data: {email: $("#billing\\:email").val()},                    complete: function (response) {                        try {                            var responseObject = $.parseJSON(response.responseText);                        } catch (ex) {                            _this._removeWait();                            return true;                        }                        if (responseObject && responseObject.success == false) {                            _this._removeWait();                            _this._openConfirmExistEmail();                        }                    }                });            });            _this._onchangeBillingLocactionFields();            this.element                .on('click', _this.options.billing.noUseForShippingAddressCheckboxId, function () {                    $(_this.options.shipping.countryDropdownSelector) && $(_this.options.shipping.countryDropdownSelector).trigger('change');                })                .on('change', this.options.billing.addressDropdownSelector, $.proxy(function (e) {                    this.element.find(this.options.billing.newAddressFormSelector).toggle(!$(e.target).val());                    if ($(_this.options.billing.useForShippingAddressCheckboxId).is(':checked')                        || _this.options.billing.alwaysUseShippingAsBilling                    ) {                        _this._updateLocation(null, 'billing_shipping');                    } else {                        _this._updateLocation(null, 'billing');                    }                }, this))                .find(this.options.billing.form).validation();            if (_this.options.autoDetectLocation) {                try {                    this.autoDetectLocation();                } catch (e) {                }            }            var that = this;            /**             * checkbox : is create new account             */            if ($("input[name=\"billing[create_new_account]\"]").checked)                $(that.options.checkout.registerCustomerPasswordSelector).show();            else                $(that.options.checkout.registerCustomerPasswordSelector).hide();            $("input[name=\"billing[create_new_account]\"]").click(function () {                if (this.checked)                    $(that.options.checkout.registerCustomerPasswordSelector).show();                else                    $(that.options.checkout.registerCustomerPasswordSelector).hide();            });            /**             * checkbox address             */                //shipping-area            $("input[name=\"billing[use_for_shipping]\"]").change(                function () {                    if ($("#billing\\:use_for_shipping_yes").length) {                        if ($("#billing\\:use_for_shipping_yes").is(":checked") == 1) {                            $("#shipping-area").hide();                        } else {                            $("#shipping-area").show();                        }                    } else {                        $("#shipping-area").hide();                    }                }            );            $("input[name=\"billing[use_for_shipping]\"]").trigger('change');            return this;        }

红色代码部分,第一个是对的,后一个原来和第一段代码是一样的,报错不是函数,改成现在的才对

0 0
原创粉丝点击