Title: Bug in expand/contract function
Last modified: August 20, 2016

---

# Bug in expand/contract function

 *  [jesusangel.delpozo](https://wordpress.org/support/users/jesusangeldelpozo/)
 * (@jesusangeldelpozo)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/bug-in-expandcontract-function/)
 * Fixed expand/contract “more options” functionality. Widget form data
    can be 
   added multiple times (i.e: one for the available widgets and one for each active
   lctw widget). Expand/contract script shows/closes all elements with class names
   lctw-expand-options and lctw-all-options without check for a particular instance.
 * This fix changes constant class names by automatically ones generated
    with get_field_id
   method so only one class is opened/closed.
 *     ```
       Index: list-custom-taxonomy-widget.php
       ===================================================================
       --- list-custom-taxonomy-widget.php     (revisión: 646137)
       +++ list-custom-taxonomy-widget.php     (copia de trabajo)
       @@ -136,20 +136,20 @@
                               jQuery(document).ready(function(){
                                       var status = jQuery('#<?php echo $this->get_field_id('expandoptions'); ?>').val();
                                       if(status == 'expand')
       -                                       jQuery('.lctw-expand-options').hide();
       +                                       jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').hide();
                                       else if(status == 'contract'){
       -                                       jQuery('.lctw-all-options').hide();
       +                                       jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').hide();
                                       }
                               });
                               function lctwExpand(id){
                                       jQuery('#' + id).val('expand');
       -                               jQuery('.lctw-all-options').show(500);
       -                               jQuery('.lctw-expand-options').hide(500);
       +                               jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').show(500);
       +                               jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').hide(500);
                               }
                               function lctwContract(id){
                                       jQuery('#' + id).val('contract');
       -                               jQuery('.lctw-all-options').hide(500);
       -                               jQuery('.lctw-expand-options').show(500);
       +                               jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').hide(500);
       +                               jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').show(500);
                               }
                               </script><?php
                         // instance exist? if not set defaults
       @@ -212,8 +212,8 @@
                               <?php } ?>
                               </select>
                               </p>
       -                       <h4 class="lctw-expand-options"><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" >More Options...</a></h4>
       -                       <div class="lctw-all-options">
       +                       <h4 class="<?php echo $this->get_field_id('lctw-expand-options'); ?>"><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" >More Options...</a></h4>
       +                       <div class="<?php echo $this->get_field_id('lctw-all-options'); ?>">
                                       <h4 class="lctw-contract-options"><a href="javascript:void(0)" onclick="lctwContract('<?php echo $this->get_field_id('expandoptions'); ?>')" >Hide Extended Options</a></h4>
                                       <input type="hidden" value="<?php echo $expandoptions; ?>" id="<?php echo $this->get_field_id('expandoptions'); ?>" name="<?php echo $this->get_field_name('expandoptions'); ?>" />
   
       @@ -250,4 +250,4 @@
   
        } // class lc_taxonomy
   
       -?>
       \ No newline at end of file
       +?>
       ```
   
 * [http://wordpress.org/extend/plugins/list-custom-taxonomy-widget/](http://wordpress.org/extend/plugins/list-custom-taxonomy-widget/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Nick Halsey](https://wordpress.org/support/users/celloexpressions/)
 * (@celloexpressions)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/bug-in-expandcontract-function/#post-3316642)
 * This was actually the intended behavior, which is why I used classes. Using ids
   has resulted in lots of unexpected behavior, because unique ids aren’t assigned
   until saving. The best workflow seems to be to expand/contract all, but for the
   user to only have one of these widgets open for editing at a time.

Viewing 1 replies (of 1 total)

The topic ‘Bug in expand/contract function’ is closed to new replies.

 * ![](https://ps.w.org/list-custom-taxonomy-widget/assets/icon.svg?rev=1225454)
 * [List Custom Taxonomy Widget](https://wordpress.org/plugins/list-custom-taxonomy-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-custom-taxonomy-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Nick Halsey](https://wordpress.org/support/users/celloexpressions/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/bug-in-expandcontract-function/#post-3316642)
 * Status: not resolved