Skip to content

Instantly share code, notes, and snippets.

@huiralb
Created October 2, 2016 16:35
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huiralb/e1710a8d6f278c3546b45b79a77133cf to your computer and use it in GitHub Desktop.
Save huiralb/e1710a8d6f278c3546b45b79a77133cf to your computer and use it in GitHub Desktop.
Fix Visual Composer 4.8 Uncaught TypeError: Cannot read property 'attributes' of undefined
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim());
if($template.get(0))
{
_.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
})};
this.$el.attr(attributes).html($template.html()),
this.setContent(),
this.renderContent()
}
@UsmanJ
Copy link

UsmanJ commented Dec 25, 2016

Thanks for this! Worked like a treat 👍

@orivelton
Copy link

Thanks for this!

@sivasakthivelkalaiarasu

Thanks working perfect...

@apostoiis
Copy link

[WP newbie here] Where should I put this function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment