My visual composer plugin doesn't work. It stuck on the loading page. And it gives an error "TypeError: .template(...).trim is not a function" Error is on this line of code: this.$controls = $(.template(template, data, vc.template_options).trim()).addClass('vc_controls');
Please help me to fix this out.
Here is the error which I get:
This article suggests rolling back your worpress version prior to 4.5. http://forums.artbees.net/t/urgent-wordpress-4-5-broken-vc-backend-editor-workaround-fix-in-comments/2734
This is where you can find older versions of wp to install https://wordpress.org/download/release-archive/30
I haven't tried this myself just a suggestion.
If this is still a problem for you I solved this same error I was getting by manually updating my theme through ftp. I downloaded the latest version of the theme because automatic updates were not working. I kept wordpress version 4.5. Here are the steps I took as follows.
These 3 steps are a little nerve racking if you are not familiar with uploading files directly to your public_html root directory of your website. Some themes may offer support and do the ftp uploading for you if you provide them with ftp username password.
One more thing to do is clear your cache for your website. In chrome you can clear your cache by going to chrome://settings/cookies enter website.com in the search bar and click remove all clearing all locally stored data for your website. Manual updating themes and plugins is recommended only if auto updates aren't possible then you do the above. For my theme and this same exact error in question I followed these really well-done steps https://community.theme.co/kb/updating-your-theme-and-plugins/. However this will be different depending which theme you have. And if you would rather roll back your wp version you can follow my original suggestion. But for me I like to have everything new and up-to-date.
One more important note if you do have this theme then I had to delete x-shortcodes plugin from plugins direcotry of my website because my updated theme uses cornerstone instead of x-shortcodes to process important shortcodes to make vc work properly. Another thing to know is none of your data should be harmed while uploading plugins and themes all the data/content is stored safely in your data-base not in your theme.
Solution Goto file /wp-content/plugins/js_composer_salient/assets/js/dist/backend.min.js around line 4045:
======> Replace the code
As Shady sherif said at Maulik's suggestion, this is what I've changed in 2 places at frontend-editor.min.js and it worked!! Thanks to you both!
Change this:
With this:
If you have Visual Composer 4.9, just replace these 2 files from archive - frontend-editor.min.js - backend.min.js
path: /wp-content/plugins/js_composer/assets/js/dist
Don't forget to make a backup of your files.
https://yadi.sk/d/JH4cbtnH3UoU3F
click "download add" (tested with VC 4.9 & WP 4.9.5)
Upgrade to Visual Composer version 4.11.2+
Note Wordpress 4.5 compatibility was fixed on 13th April: https://wpbakery.atlassian.net/wiki/display/VC/Release+Notes
If you are unable to solve this error by upgrading or downgrading your theme or plugin, you could at least make the below changes.
1. Open the following two files:
2. Replace
this.$controls = $( _.template( template, data, vc.template_options ).trim() ).addClass( 'vc_controls' ); with
this.$controls = $( ( "vc.template_options" ).trim() ).addClass( 'vc_controls' );
This will surely work.