Question

Nous utilisons l'affichage de code Follwing comme suit cette "image 1": http://prntscr.com/8w7f5v :

<td>
     <?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
      <input type = "text" id = "qty_<?php echo $products->getId(); ?>" name = "qty" value = "<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>" style = "display:none"/>

    <span class = "label wk_action">
      <img onclick = "updateField('<?php echo $products->getId(); ?>'); " 
      src = "<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>    

        <br/>

    <button class="button wk_mp_btn1" title="<?php echo $helper->__('Save') ?>" type="submit" id="save_butn">
    <span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
    </button>



    <button type="reset" class="button wk_mp_btn1" onclick="updateField('<?php echo $products->getId(); ?>');return false;">
    <span><span><?php echo $helper->__('Cancel') ?></span></span>
    </button>
         </td>

Si nous cliquons sur le bouton Modifier, son affichage de cette "image 2": http://prntscr.com/8w7fdp

Ce dont j'ai besoin est

a) Si nous cliquons sur le bouton Modifier, uniquement sur le bouton "Mettre à jour" et "Annuler" doit être visible et "Modifier" doit masquer.

B) Plus tard si nous cliquons sur le bouton "Annuler", le bouton "Mettre à jour" doit masquer et "Modifier" doit être visible.

Était-ce utile?

La solution

Essayez quelque chose comme, je ne suis pas sûr que cela fonctionne ou non

<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
        <img onclick="updateField('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>  

    <br/>
    <button id="update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" title="<?php echo $helper->__('Save') ?>" type="submit" id="save_butn">
        <span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
    </button>

    <button id="reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideReset('<?php echo $products->getId(); ?>'); return false;">
        <span><span><?php echo $helper->__('Cancel') ?></span></span>
    </button>

et modifier le script selon

<script type = "text/javascript" >

        var $wk_jq = jQuery.noConflict();

        function hideReset(product_id) {
            var editLink = "#edit_link_"+ product_id;
            var updateButton = "#update_button_"+ product_id;
            var resetButton = "#reset_button"+ product_id;

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

        function updateField(product_id)
        {
            var qtyId = '#qty_'+ product_id;

            var editLink = "#edit_link_"+ product_id;
            var updateButton = "#update_button_"+ product_id;
            var resetButton = "#reset_button"+ product_id;

            $wk_jq(qtyId).toggle()

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

            $qty = $wk_jq(qtyId).val();

            new Ajax.Request('<?php echo $url ?>', {
                method: 'post',
                parameters: {id: product_id, qty: $qty}
            });
        }
    </script>

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top