Add Jquery in Raw Element

I am trying to add Jquery to a V2 Raw Content element.

When I add it I get the functionality needed, but it will output the code on the front ent and also show the rest of the shortcode for the page.

When I use a Classic Raw Content element with the same code it works fine and nothing is displayed on the front end.

Here is the code: https://pastebin.com/2XPc0p0D

This is on a local site so I cannot provide a link. There is no errors in the console.

It looks like maybe lines 30 and 31 in the JS might be the issue.

target--;
if (target < 0) target = lengthMinusOne;

When I remove these lines out the text is not rendered on the frontend, but I do lose the functionality of my button clicking backwards.

Hi @designerken,

Thank you for writing in, try adding your code in the JS area without the opening <script type='text/javascript'> and closing </script> tag.

Hope it helps,
Cheers!

@friech

No that doesn’t help.

The reason I am moving from the JS area is because I will add this section as a Global Block and don’t want the JS on every page (Global section) or trying to remember to add it to the specific page(s) that it resides with the block. Also If I export out the section as a template the JS will not come along with it.

Hi @designerken,

I’ve looked into this and can confirm there’s something going on where certain JS breaks the output. It’s actually in how SEO data gets stored in posts and pages. We’ll get this corrected for a future release. If you put the code in a Global Block it won’t behave this way fortunately. Until this is fixed, I would advise using the classic element or a Global Block.

@alexander

I have tested with a V2 Raw element and Global Block and can confirm that there is no output in the front end.

Thanks.

Hello @designerken,

I have tested it on the Global block and Classic element as suggested by @@alexander it seems to be working at my end. Please have a look at my structure.
testblock-Global-Blocks-Pro

testblock-Global-Blocks-Pro

In case if it doesn’t work for you we need to check your settings please share your details in a secure note. Please provide the following details

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts

Thanks

@prakash_s

First, thanks for chiming in…Second, maybe you should re-read my previous comment? I stated that I tested in a Global Block and it worked as @alexander stated no code is output on the frontend. Third, you are not using a classic element in your images, you are using the V2 element. Lastly, why wouldn’t you test with the same JS as I supplied?

No need for a reply, I have it sorted per Alexander’s recommendation with a V2 Raw Content in a Global Block.

Hi @designerken,

We’re glad that you’re able to figure it out! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.