My hosting provider automatically updated to 4.5 and it resulted in an error with the Visual Composer plugin.
I DID READ THESE POSTS: Plugin throwing TypeError after Wordpress 4.5 update
Visual composer doesn't load and gives TypeError: _.template(...).trim is not a function
Uncaught TypeError: $template.get is not a function
And replaced the html2element function with the one provided. However, as many people commented on these posts, I get a new error:
composer-view.js?ver=4.6.1:139 Uncaught TypeError: Cannot read property 'attributes' of undefined
Here is my function:
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
}), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
},
The error seems to be coming from this line:
$template.get(0).attributes
Has anyone figured out how to fix it ?
Thanks for your help