单击更新按钮后隐藏更新和取消按钮

时间:2015-11-09 12:09:35

标签: javascript jquery ajax magento

我们正在使用此代码更新价格。

点击"更新"按钮就像在图像中一样显示。

我们需要的是一旦我们点击"更新"按钮,然后"更新"和"取消"按钮应该隐藏。现在,一旦我们刷新页面,那么只有"更新"和"取消"按钮是隐藏的,但它应该在重新映射页面之前发生。我需要这样的东西:https://jsfiddle.net/g1v9x1bt/

对于"取消"按钮,它工作正常。一旦我们点击"取消"按钮,然后"更新"和"取消"按钮隐藏

<span class="label pro_status">
    <?php //echo $products->getPrice(); ?>

        <span id="valueprice_<?php echo $products->getId(); ?>"><?php echo $products->getPrice(); ?></span>
    <input type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getPrice(); ?>" style = "display:none"/>


    <!-- aki 2 -->
    <span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
<img onclick="showFieldPrice('<?php echo $products->getId(); ?>'); return false;" 
src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
        </span>  
    <p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red;">Updated</p><br/>
    <button id="price_update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
                <span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
                                                        </button>
    <button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span><?php echo $helper->__('Cancel') ?></span></span>
                                                        </button>                                                       
                                                    </span>

脚本

<script>
function updateFieldPrice(product_id)
        {
            var priceId = '#price_'+ product_id;
            var valueId = '#valueprice_'+ product_id;
            var updatedqty = '#updatedprice_'+ product_id;


            var editLink = "#price_edit_link_"+ product_id;
            var updateButton = "#price_update_button_"+ product_id;
            var resetButton = "#price_reset_button"+ product_id;
            var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldPrice/')?>';

            $wk_jq(priceId).toggle()

            $wk_jq(editLink).hide();
            $wk_jq(updateButton).show();
            $wk_jq(resetButton).show();

            $price = $wk_jq(priceId).val();
            jQuery(valueId).html($price);
            hideReset(product_id);

1 个答案:

答案 0 :(得分:0)

因此,根据您的要求,fiddle会对您有所帮助。

元素对象

var $updateButton = $wk_jq("#update_button_"+ product_id);

您可以使用以下代码禁用按钮:

var $updateButton = $wk_jq("#update_button_"+ product_id);

重置按钮对象

var $resetButton = $wk_jq("#update_button_"+ product_id);

禁用

此处您正在更新仅更新按钮的禁用属性。

$updateButton.prop('disabled', true);

隐藏

$updateButton.hide();
$resetButton.hide();