{"id":17657,"date":"2015-02-27T17:49:23","date_gmt":"2015-02-27T12:19:23","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=17657"},"modified":"2015-02-27T17:49:23","modified_gmt":"2015-02-27T12:19:23","slug":"hide-a-cq-parsys-in-edit-mode","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/hide-a-cq-parsys-in-edit-mode\/","title":{"rendered":"Hide a CQ parsys in edit mode"},"content":{"rendered":"<p>Often, a situation is encountered in CQ where we have a number of parsys on our page and it is\u00a0required to show\/hide some of them on certain events. A typical use case is that of a Tabbed Component where the parsys associated with a particular tab needs to be shown only on click of that particular tab while the parsys for all the other non active tabs should be hidden.<\/p>\n<p>If my parsys is wrapped by a container div something like this.<\/p>\n<p>&lt;div class=&#8221;genericTabContent&#8221;&gt;&lt;cq:include path=&#8221;par&#8221; resourceType=&#8221;foundation\/components\/parsys&#8221; \/&gt;<br \/>\n&lt;\/div&gt;<\/p>\n<p>Then, calling the .hide() method on the div doesn&#8217;t hide the parsys. Rather, the parsys is visible floating somewhere on\u00a0the page making the authoring experience very tough.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/02\/parsys1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17661\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/02\/parsys1.jpg\" alt=\"parsys1\" width=\"579\" height=\"250\" \/><\/a><\/p>\n<p>All attempts to hide the parsys through CSS seem to fail.<\/p>\n<p>A possible solution is :<\/p>\n<p>var parsysComp = CQ.WCM.getEditable(&#8220;path to the parsys&#8221;);<br \/>\nparsysComp.hide(); \/\/ makes the parsys visible<br \/>\nparsysComp.show(); \/\/ hides the parsys<\/p>\n<p>To get the path to the parsys, the current node path can be fetched on our jsp page:<br \/>\n&lt;div id=&#8221;currentNodePath&#8221; class=&#8221;${currentNode.path}&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>Once the current node path is known, this code snippet would work:<br \/>\nvar parsysComp = CQ.WCM.getEditable((&#8216;#currentNodePath&#8217;).attr(&#8216;class&#8217;)+&#8221;\/par&#8221;);<\/p>\n<p>Hope this was helpful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often, a situation is encountered in CQ where we have a number of parsys on our page and it is\u00a0required to show\/hide some of them on certain events. A typical use case is that of a Tabbed Component where the parsys associated with a particular tab needs to be shown only on click of that [&hellip;]<\/p>\n","protected":false},"author":162,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":6},"categories":[1],"tags":[4847,1657,1246,1655,1656],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17657"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/162"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=17657"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17657\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=17657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=17657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=17657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}