Visual Composer error in WordPress, after updating to WP 4.5

This is the code that is coming up with an error from the console.

 /**
     * Convert html into correct element
     * @param html
     */
    html2element:function (html) {
        var attributes = {},
            $template;
        if (_.isString(html)) {
            this.template = _.template(html);
            $template = $(this.template(this.model.toJSON()).trim());
        } else {
            this.template = html;
            $template = html;
        }
        _.each($template.get(0).attributes, function (attr) {
            attributes[attr.name] = attr.value;
        });
        this.$el.attr(attributes).html($template.html());
        this.setContent();
        this.renderContent();
    },

it causes the page editor not to load!

Read More

see the line where there is an error in the code.

I apologise in advance if i have broken any rules or not explained the problem in enough detail.

Please advise if possible.

Related posts

1 comment

  1. Please see my answer here.

    I fixed this bug by updating the html2element function to:

    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()
        },
    

    in /wp-content/plugins/js_composer/assets/js/backend/composer-view.js

    Hope this works for you!

Comments are closed.