1

I'm using the b2b order list extension which changes the way products are displayed (in this example I'm using grouped products)...

By default you have to click a link for the simple products to become visible, the links is...

<a href="#" id="openproducts" onclick="getProductOptions(this); return false;">

that triggers the following function;

    function getProductOptions(link){
        jQuery(link).parents("tr").next("tr").find('.complex-product-children').find("select").each(function(){
            if(jQuery(this).hasClass('required-entry-b2borderlist')){
                jQuery(this).removeClass('required-entry-b2borderlist').addClass('required-entry');
            }
        })

        jQuery(link).parents("tr").next("tr").find('.complex-product-children').find("input[type='radio']").each(function(){
            if(jQuery(this).hasClass('validate-one-required-by-name-b2borderlist')){
                jQuery(this).removeClass('validate-one-required-by-name-b2borderlist').addClass('validate-one-required-by-name');
            }
        })

        jQuery(link).parents("tr").next("tr").find('.complex-product-children').find("input[type='checkbox']").each(function(){
            if(jQuery(this).hasClass('validate-one-required-by-name-b2borderlist')){
                jQuery(this).removeClass('validate-one-required-by-name-b2borderlist').addClass('validate-one-required-by-name');
            }
        })
        jQuery(link).parents("tr").next("tr").find('.complex-product-children').show();
    }

Is there any way for me to make it so the link doesn't need to be clicked and its automatically open? I tried doing a trigger click like this;

jQuery(document).ready(function(){
 jQuery("#openproducts").trigger('click');
});

Which works but only for the first product?

Thanks in advance

1
  • do you have more than one link with an id of 'openproducts'?
    – jscar
    Sep 7, 2017 at 7:56

2 Answers 2

2
+50

You cannot do it using id of the element. You need to add a class to your a tag and then loop through all links to trigger click event.

<a href="#" class="openproducts" id="openproducts" onclick="getProductOptions(this); return false;">

Trigger click on each element.

jQuery(document).ready(function(){
   jQuery(".openproducts").each(function (){
       jQuery(this).trigger('click');
   });
});
0
0

HTML

<a href="#" id="openproducts-<?php echo $_product->getId()?>" onclick="getProductOptions(this); return false;">

JS

jQuery(document).ready(function(){
 jQuery("#openproducts-<?php echo $_product->getId()?>").trigger('click');
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.