9 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
wplab says

Hello everybody! I’m looking an advice, if you have experience with new Visual Composer Frontend builder, please.

How to init my own carousel javascript in a shortcode at VC Frontend editor?

I use “wp_enqueue_scripts” to load my front-end JS, but it doesn’t work when i add a shortcode in VC front editor.

thank you so much

373 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
WPWiseOwl says

Have you viewed the page source in the browser and checked to see whether the JS path is actually valid / resolves? Any errors in the console?

Regardless of whether you use “wp_enqueue_scripts” or no, if it’s a bad url then it’s not going to load. Where / in what file are you enqueuing? Are you using an hook to run the enqueue code? This is all not at all specific to VC but JS and WP.

Aside from that also have a look here for VC specifics when you’re sure of the rest – http://kb.wpbakery.com/index.php?title=Category:Visual_Composer

1083 posts
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 3-4 years
  • Exclusive Author
+1 more
Smartik says

This is all not at all specific to VC but JS and WP.
I have not tried Visual Composer but I guess the problem here is in WP but in the plugin itself. Basically it should init/create the carousel javascript after it is added. If the js that call the carousel is in an external file then it probably is not going to be loaded again, it is loaded only once when the page is ready. This is something like jQuery ajax where you have to re-init the js when ajax is complete.
9 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
wplab says

Thank you for reply.

There are no errors in JS console, also i read documentation and tried to get support from WPBakery, they promised write me an example, the right way to init JS, but promises remained promises for the past two weeks, it is sad :(

I will try to explain

I keep all the JS functions for front-end in a single file, it loads and works well, as the rest parts of the theme works fine, like widgets, that uses JS from that file.

I believe that i need to call some hook to init my carousel when shortcode is loaded, but i did not find any docs how to do that.

9 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
wplab says

i’ve found a temporary solution, to call JS function in a shortcode template, but I’m not sure that this is a right way. what do you think? anyway thanks for your answers!

9 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
wplab says

just got a reply from WPbakery, I had to do what I did, i need to call my init function from a shortcode template. In my opinion, it is not very correct, but it works.

by
by
by
by
by
by