Javascript Wordpress更新后的插件错误

Javascript Wordpress更新后的插件错误,javascript,jquery,wordpress,Javascript,Jquery,Wordpress,我的主机提供商自动更新为4.5,导致Visual Composer插件出错 我确实读过这些帖子: 并将html2element函数替换为提供的函数。然而,正如许多人对这些帖子发表评论一样,我发现了一个新的错误: composer-view.js?ver=4.6.1:139 Uncaught TypeError: Cannot read property 'attributes' of undefined 以下是我的功能: html2element: function(html) {

我的主机提供商自动更新为4.5,导致Visual Composer插件出错

我确实读过这些帖子:

并将html2element函数替换为提供的函数。然而,正如许多人对这些帖子发表评论一样,我发现了一个新的错误:

composer-view.js?ver=4.6.1:139 Uncaught TypeError: Cannot read property 'attributes' of undefined
以下是我的功能:

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()
        },
错误似乎来自这一行:

$template.get(0).attributes
有人知道怎么修吗

谢谢你的帮助,格雷厄姆,你好

我认为问题不在于jquery,而在于js_composer中使用的下划线

在render方法中,将错误的html对象传递给html2element方法,如下所示:

 this.html2element(_.template($shortcode_template_el.html(),
            this.model.toJSON(),
             vc.templateOptions.default));
但这段代码将html对象作为函数发送到html2element方法,该函数没有任何属性或其他内容。之所以发生这种情况,是因为下划线库中的.template函数没有在第二个参数之前呈现第一个参数(html模板),而第一个参数没有有效的变量

在我看来,要解决这个问题,需要这样做:

this.html2element(_.template($shortcode_template_el.html()));
这两个方法分别是render和html2element

我使用js_composer 4.7.4和wordpress 4.5.2解决了这个问题

谢谢

更新: 抱歉,在html2element中,需要进行一次更改,来自:

            if ( _.isString( html ) ) {
            this.template = _.template( html );
            $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() );
        } else {
            this.template = html;
            $template = html;
        }
致:


4.5更新也有同样的问题,我尝试了我发现的所有东西,但仍然不起作用

最后,我用最近的一个插件(4.11.2,googlejs_composer.zip)替换了我的主题可视化编写器插件(v4.7左右)


我刚刚替换了整个目录内容,效果很好。

你是个救命稻草!这一个工作,但它基本上是一个版本的独立视觉作曲家插件安装在一个网站上,你应该支付,而不是从另一个网站复制。我下载了你答案中的zip文件进行测试,它成功了。然后我购买了插件(大约30美元)(),这样我也可以在晚上睡觉:-)这取决于人们如何做,但我认为这是很好的了解。@bestprogrammerintheworld你确定你没有支付两次吗?它出现在你的主题中是有原因的,主题和插件制造商之间经常有协议。但你是对的,这是一个紧急补丁。我把许可证问题交给了每个人:)@FLX-我确实比我需要支付的更多,但我不在乎。这将花费我更多的时间来参与主题制作人,让他们解决这个问题。Bridge theme的最新版本不包括VisualComposer的正确版本,至少现在不包括。为我工作。很难找到新版本的VC。到今天为止的工作链接是。您需要VPN才能访问此页面。在少数几个国家,它受到限制。您还需要一个rar实用程序来提取其内容。然后使用js_composer.zip文件,就完成了。谢谢。这只“一点点”管用。可以编辑图元,但不能添加任何图元。
            if ( _.isString( html ) ) {
            this.template = _.template( html );
            $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() );
        } else {
            this.template = html;
            $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() );
        }