Title: Advanced Tab Block: switching tabs losing the content generated by a script
Last modified: January 7, 2022

---

# Advanced Tab Block: switching tabs losing the content generated by a script

 *  Resolved [ooker](https://wordpress.org/support/users/ooker/)
 * (@ooker)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/)
 * I have multiple graphs to display and want to sort them using the Advanced Tab
   Block. In each tab the content is like this:
 * `<code class="beliefnetwork" id="tab2" cypherstring="match (n)-[r]-(m) where 
   n.gid='Kt' and m.gid='Kt' return n,r,m"></code>`
 * When the page first reload, the first tab does generate the graph. But if I switch
   tab 2, the graph in tab 2 doesn’t show up. If I switch back to tab 1, the graph
   in tab 1 disappears.
 * Why does this happen? [Here is the test page](https://quảcầu.cc/test-2/?utm_source=Support+%C2%BB+Plugin%3A+Gutenberg+Blocks+-+PublishPress+Blocks+Gutenberg+Editor+Plugin&utm_medium=test&utm_campaign=Get+help).
   If you open the view source you can see the js script that generates the graph.
   I don’t post it here because it’s quite long, and I don’t think it has much relevance
   to this issue.
    -  This topic was modified 4 years, 4 months ago by [ooker](https://wordpress.org/support/users/ooker/).

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15228150)
 * Hi [@ooker](https://wordpress.org/support/users/ooker/),
    please share the HTML
   from [Code editor](https://ibb.co/J7JDZbF). Use an online service such as Google
   Drive to share the content.
 * Regards
 *  Thread Starter [ooker](https://wordpress.org/support/users/ooker/)
 * (@ooker)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15228519)
 * Here is the [pastebin](https://pastebin.com/3sDQ5Ufd). What is interesting is,
   when I visit it again the issue has partly disappeared. The each tab I have two
   elements to test: `<div>` and `<code>`. `<div>` works, but `<code>` doesn’t, 
   even though outside of the tab `<code>` still works. But if you look at the tab
   3, it still works
    -  This reply was modified 4 years, 4 months ago by [ooker](https://wordpress.org/support/users/ooker/).
 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15229235)
 * Thanks!
 * 1. Is the script tag inserted inside the post? If that’s the case, don’t load
   the javascript through the post content.
    2. The third tab has a paragraph as
   only content. The code for this tab is outside. This can be seen in List view.
   [https://ibb.co/JqqLXZV](https://ibb.co/JqqLXZV)
 *  Thread Starter [ooker](https://wordpress.org/support/users/ooker/)
 * (@ooker)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15229431)
 * 1. Yes, the js script is inserted via the custom HTML block. What do you mean
   by not loading it through the post content?
    2. Yes sorry. I somehow mistaken
   this test version with an old version test. The code outside is to test that 
   it still work outside the block. We only need 2 tabs to test this. The problem
   of “`<div>` works, but `<code>` doesn’t” is still correct for the first two tabs.
 * Anyhow, can you reproduce the problem?
    -  This reply was modified 4 years, 4 months ago by [ooker](https://wordpress.org/support/users/ooker/).
 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15229680)
 * 1. Javascript is recommended to be added through the theme, plugin, etc.
    2. 
   Inside the tab content add a group block and inside the group place the code.
   See if makes a difference.
 * Please double check the structure is fine in Editor List view.
 *  Thread Starter [ooker](https://wordpress.org/support/users/ooker/)
 * (@ooker)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15230497)
 * 1. I see. Can I insert it via shortcode? (Btw, I open a discussion in WordPress
   Stack Exchange about this. You can comment on this further if you like [Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?](https://wordpress.stackexchange.com/q/401086/64282))
   
   2. I add a group block and inside the group I place the div and code elements.
   Now the code element does show the graph at the first time, but then if I switch
   to another tab and switch back, it disappears.
 * Is this structure fine? [https://i.imgur.com/JrTKQcr.png](https://i.imgur.com/JrTKQcr.png).
   I’ve also updated the [pastebin](https://pastebin.com/3sDQ5Ufd)
    -  This reply was modified 4 years, 4 months ago by [ooker](https://wordpress.org/support/users/ooker/).
 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15235985)
 * 1. The first comment on WP Slack provide valid reasons why JS shouldn’t be added
   via post content.
    2. Looks fine to me, however there is extra content after 
   the Tabs. If this is the desired result, then all is fine.
 * Regards
 *  Thread Starter [ooker](https://wordpress.org/support/users/ooker/)
 * (@ooker)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15238552)
 * 2. If you visit the [test page](https://xn--qucu-hr5aza.cc/test-2/?utm_source=Support+%C2%BB+Plugin%3A+Gutenberg+Blocks+-+PublishPress+Blocks+Gutenberg+Editor+Plugin&utm_medium=test&utm_campaign=Get+help)
   you will see that the problem still exists
 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/why-does/#post-15240341)
 * May you elaborate?
 *  Plugin Author [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * (@htmgarcia)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/why-does/#post-15365192)
 * Closing after 1 month of no reply.
 * Regards

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Advanced Tab Block: switching tabs losing the content generated by a 
script’ is closed to new replies.

 * ![](https://ps.w.org/advanced-gutenberg/assets/icon-256x256.png?rev=3393761)
 * [PublishPress Blocks - Block Controls, Block Visibility, Block Permissions](https://wordpress.org/plugins/advanced-gutenberg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-gutenberg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-gutenberg/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-gutenberg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-gutenberg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-gutenberg/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [htmgarcia](https://wordpress.org/support/users/htmgarcia/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/why-does/#post-15365192)
 * Status: resolved