Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CP9 - How to Show a group of objects?

Engaged ,
Mar 16, 2018 Mar 16, 2018

CP9

HTML5 only

Hello,

My Question is:

How do I alter the code to Show objects that are currently hidden?

Background:

Following on from this thread:CP9 - Hide a Group using JavaScript - Is there a better solution?

The thread above used code created by TLCMediaDesign and used jQuery to hide objects which have a similar name.

     hideGroup('doctor');

     function hideGroup( which )

     {

     $("*[id*="+ which +"]:visible").each(function()

     {

       cp.hide( $(this).attr( "id" ));

     });

     }

I now need the opposite of this, I want to show the group of objects.

I have looked at the jQuery documentation and it seems to suggest that the opposite of :visible is :hidden.

I changed he code to this, but it did not work.

     $("*[id*="+ which +"]:hidden").each(function()

     {

       cp.show( $(this).attr( "id" ));

What I did discover is that:

     When $(this).attr( "id" ) is used with visible it produces the correct id name, such as doctor.

     When $(this).attr( "id" ) is used with hidden it produces the id name with accStr tagged on the end, such as doctoraccStr.

That seems to be some sort of string error, but I could not find any reference to explain it.

Any help with this would be much appreciated.

Thank you

Peter.

PS This is my first venture in to jQuery, it looks like Egyptian hieroglyphics, but it also looks very interesting in what it can do.

345
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Mar 21, 2018 Mar 21, 2018

Hello,

I figured it out.

The HIDE function worked fine, but the SHOW function was tagging the text 'accStr' to the end of the name of the item to show.

To make the SHOW function work I replaced the 'accStr' with nothing.

Hope this helps anyone else.

This is the original function that HIDES items.

     function myHideByName(tmpItemToHide)

     {

     $("*[id*="+ tmpItemToHide +"]:visible").each(function()

     {

     cp.hide($(this).attr("id"));

     });

     }

This is the function that SHOWS items.

     funct

...
Translate
Engaged ,
Mar 21, 2018 Mar 21, 2018
LATEST

Hello,

I figured it out.

The HIDE function worked fine, but the SHOW function was tagging the text 'accStr' to the end of the name of the item to show.

To make the SHOW function work I replaced the 'accStr' with nothing.

Hope this helps anyone else.

This is the original function that HIDES items.

     function myHideByName(tmpItemToHide)

     {

     $("*[id*="+ tmpItemToHide +"]:visible").each(function()

     {

     cp.hide($(this).attr("id"));

     });

     }

This is the function that SHOWS items.

     function myShowByName(tmpItemToShow)

     {

     $("*[id*="+ tmpItemToShow +"]:hidden").each(function()

     {

     // Remove the 'accStr' that gets tagged on to the end of the string.

     var tmpItemToShow = $(this).attr("id").replace("accStr","");

     cp.show(tmpItemToShow);

     });

     }

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources