保存信息后使用jQuery隐藏按钮

用户名

我尝试在我的prestashop结帐页面中隐藏“保存”按钮。默认情况下,当来宾字段中的所有字段都需要单击“保存”按钮。奇怪但按钮不会消失。可能是默认js中的某些内容不正确,但我不想触摸它。我想用小jQuery隐藏此按钮。

您可以在以下位置实时查看它:test.detelinmarkov.com/quick-order我尝试做的事情:当信息正确并已保存时,客户会看到消息“帐户信息已成功保存”,当此消息显示“保存”时,我会尝试按钮隐藏。

注意:在我尝试获取成功保存的数据的ID之前,因为如果客户返回其他页面或刷新结帐页面,则“帐户信息已成功保存”会消失并且按钮会停留在那里。

和我尝试的代码,但不起作用...

                {literal}
            <script>
            $('input[name=opc_account_saved]')
                .click(
                     function ()
                     {
                         $(this).hide();

                         $("savebutton").hide();
                     }
                );
            </script>
            {/literal}
            <div id="savebutton">
            <p class="submit">
                <input type="submit" class="exclusive button" name="submitAccount" id="submitAccount" value="{l s='Save'}" />
            </p>
            </div>
            <p style="display: none;" id="opc_account_saved">
                {l s='Account information saved successfully'}
            </p>

默认情况下,按钮不消失的问题可能是在此js:

$(function() {
// GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT
if ((!isLogged) || (isGuest))
{
    if (guestCheckoutEnabled && !isLogged)
    {
        $('#opc_account_choice').show();
        $('#opc_account_form, #opc_invoice_address').hide();

        $('#opc_createAccount').click(function() {
            $('.is_customer_param').show();
            $('#opc_account_form').slideDown('slow');
            $('#is_new_customer').val('1');
            $('#opc_account_choice, #opc_invoice_address').hide();
            updateState();
            updateNeedIDNumber();
            updateZipCode();
        });
        $('#opc_guestCheckout').click(function() {
            $('.is_customer_param').hide();
            $('#opc_account_form').slideDown('slow');
            $('#is_new_customer').val('0');
            $('#opc_account_choice, #opc_invoice_address').hide();
            $('#new_account_title').html(txtInstantCheckout);
            $('#submitAccount').prop({id : 'submitGuestAccount', name : 'submitGuestAccount'});
            updateState();
            updateNeedIDNumber();
            updateZipCode();
        });
    }
    else if (isGuest)
    {
        $('.is_customer_param').hide();
        $('#opc_account_form').show('slow');
        $('#is_new_customer').val('0');
        $('#opc_account_choice, #opc_invoice_address').hide();
        $('#new_account_title').html(txtInstantCheckout);
        updateState();
        updateNeedIDNumber();
        updateZipCode();
    }
    else
    {
        $('#opc_account_choice').hide();
        $('#is_new_customer').val('1');
        $('.is_customer_param, #opc_account_form').show();
        $('#opc_invoice_address').hide();
        updateState();
        updateNeedIDNumber();
        updateZipCode();
    }

    // LOGIN FORM
    $('#openLoginFormBlock').click(function() {
        $('#openNewAccountBlock').show();
        $(this).hide();
        $('#login_form_content').slideDown('slow');
        $('#new_account_form_content').slideUp('slow');
        return false;
    });
    // LOGIN FORM SENDING
    $('#SubmitLogin').click(function() {
        $.ajax({
            type: 'POST',
            headers: { "cache-control": "no-cache" },
            url: authenticationUrl + '?rand=' + new Date().getTime(),
            async: false,
            cache: false,
            dataType : "json",
            data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#login_passwd').val())+'&token=' + static_token ,
            success: function(jsonData)
            {
                if (jsonData.hasError)
                {
                    var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
                    for(var error in jsonData.errors)
                        //IE6 bug fix
                        if(error !== 'indexOf')
                            errors += '<li>'+jsonData.errors[error]+'</li>';
                    errors += '</ol>';
                    $('#opc_login_errors').html(errors).slideDown('slow');
                }
                else
                {
                    // update token
                    static_token = jsonData.token;
                    updateNewAccountToAddressBlock();
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus !== 'abort')
                    alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
            }
        });
        return false;
    });

    // INVOICE ADDRESS
    $('#invoice_address').click(function() {
        bindCheckbox();
    });

    // VALIDATION / CREATION AJAX
    $('#submitAccount').click(function() {
        $('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')

        var callingFile = '';
        var params = '';

        if (parseInt($('#opc_id_customer').val()) == 0)
        {
            callingFile = authenticationUrl;
            params = 'submitAccount=true&';
        }
        else
        {
            callingFile = orderOpcUrl;
            params = 'method=editCustomer&';
        }

        $('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() {
            if ($(this).is('input[type=checkbox]'))
            {
                if ($(this).is(':checked'))
                    params += encodeURIComponent($(this).attr('name'))+'=1&';
            }
            else if ($(this).is('input[type=radio]'))
            {
                if ($(this).is(':checked'))
                    params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
            }
            else
                params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
        });
        $('#opc_account_form select:visible').each(function() {
            params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
        });
        params += 'customer_lastname='+encodeURIComponent($('#customer_lastname').val())+'&';
        params += 'customer_firstname='+encodeURIComponent($('#customer_firstname').val())+'&';
        params += 'alias='+encodeURIComponent($('#alias').val())+'&';
        params += 'other='+encodeURIComponent($('#other').val())+'&';
        params += 'is_new_customer='+encodeURIComponent($('#is_new_customer').val())+'&';
        // Clean the last &
        params = params.substr(0, params.length-1);

        $.ajax({
            type: 'POST',
            headers: { "cache-control": "no-cache" },
            url: callingFile + '?rand=' + new Date().getTime(),
            async: false,
            cache: false,
            dataType : "json",
            data: 'ajax=true&'+params+'&token=' + static_token ,
            success: function(jsonData)
            {
                if (jsonData.hasError)
                {
                    var tmp = '';
                    var i = 0;
                    for(var error in jsonData.errors)
                        //IE6 bug fix
                        if(error !== 'indexOf')
                        {
                            i = i+1;
                            tmp += '<li>'+jsonData.errors[error]+'</li>';
                        }
                    tmp += '</ol>';
                    var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
                    $('#opc_account_errors').slideUp('fast', function(){
                        $(this).html(errors).slideDown('slow', function(){
                            $.scrollTo('#opc_account_errors', 800);
                        });                         
                    }); 
                }
                else
                {
                    $('#opc_account_errors').slideUp('slow', function(){
                        $(this).html('');
                    });
                }

                isGuest = parseInt($('#is_new_customer').val()) == 1 ? 0 : 1;
                // update addresses id
                if(jsonData.id_address_delivery !== undefined && jsonData.id_address_delivery > 0)
                    $('#opc_id_address_delivery').val(jsonData.id_address_delivery);
                if(jsonData.id_address_invoice !== undefined && jsonData.id_address_invoice > 0)
                    $('#opc_id_address_invoice').val(jsonData.id_address_invoice);                  

                if (jsonData.id_customer !== undefined && jsonData.id_customer !== 0 && jsonData.isSaved)
                {
                    // update token
                    static_token = jsonData.token;

                    // It's not a new customer
                    if ($('#opc_id_customer').val() !== '0')
                        if (!saveAddress('delivery'))
                            return false;

                    // update id_customer
                    $('#opc_id_customer').val(jsonData.id_customer);

                    if ($('#invoice_address:checked').length !== 0)
                    {
                        if (!saveAddress('invoice'))
                            return false;
                    }

                    // update id_customer
                    $('#opc_id_customer').val(jsonData.id_customer);

                    // force to refresh carrier list
                    if (isGuest)
                    {
                        isLogged = 1;
                        $('#opc_account_saved').fadeIn('slow');
                        $('#submitAccount').hide();
                        updateAddressSelection();
                    }
                    else
                        updateNewAccountToAddressBlock();
                }
                $('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow');
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus !== 'abort')
                    alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
                $('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
            }
        });
        return false;
    });
}

bindCheckbox();
bindInputs();

$('#opc_account_form input,select,textarea').change(function() {
    if ($(this).is(':visible'))
    {
        $('#opc_account_saved').fadeOut('slow');
        $('#submitAccount').show();
    }
});

});

Pranav C Balan

缺少#您的id选择

$("#savebutton").hide();
//-^-----

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用jQuery和PHP登录后无法隐藏登录按钮

来自分类Dev

提交帐户后使用jQuery隐藏按钮

来自分类Dev

使用jQuery 5 秒后隐藏滚动按钮?

来自分类Dev

保存/创建后angularjs隐藏/显示添加按钮

来自分类Dev

使用jQuery检查单选按钮时保存隐藏字段和单选输入值的值

来自分类Dev

使用php和css单击按钮后总是隐藏按钮

来自分类Dev

单击后隐藏按钮

来自分类Dev

单击后隐藏按钮

来自分类Dev

使用Jquery单击隐藏的文件上传按钮?

来自分类Dev

使用jQuery在ruby中显示/隐藏按钮

来自分类Dev

jQuery使用单选按钮隐藏和显示

来自分类Dev

jQuery-validate:使用远程隐藏按钮?

来自分类Dev

显示/隐藏信息jQuery

来自分类Dev

在jQuery中单击任何按钮后如何隐藏文本

来自分类Dev

使用Jquery ui单击按钮后保存新的ul列表顺序

来自分类Dev

使用jQuery在标签后隐藏文本

来自分类Dev

使用保存功能单击应用栏后,无法更新信息

来自分类Dev

单击并使用 LocalStorage 保存后如何隐藏横幅?

来自分类Dev

jQuery隐藏确定按钮

来自分类Dev

jQuery和隐藏的按钮

来自分类Dev

使用jQuery删除提交按钮(验证后)

来自分类Dev

音频结束后隐藏按钮

来自分类Dev

返回按钮后隐藏片段

来自分类Dev

单击后隐藏提交按钮

来自分类Dev

AngularJS:单击后隐藏按钮

来自分类Dev

使用jQuery Cookie使用单选按钮显示/隐藏div

来自分类Dev

jQuery删除后隐藏

来自分类Dev

单击按钮后如何隐藏按钮?

来自分类Dev

切换按钮-显示/隐藏信息