我有一些视觉作曲家的问题。由于旧版本,无法获得支持。顾客不会付钱。问题是我不能在后端添加元素。chrome调试出错:
我已经尝试用代码修复这个问题:未捕获TypeError:无法读取未定义的属性'attributes‘
<pre>
html2element @ composer-view.js?ver=4.7.4:156
render @ composer-view.js?ver=4.7.4:163
addShortcode @ composer-view.js?ver=4.7.4:232
addShortcode @ composer-view.js?ver=4.7.4:561
_ @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
m @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
f @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
l.trigger @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
ListenerHelper.triggerShortcodeEvents @ events.js?ver=4.7.4:19
(anonymous function) @ composer-view.js?ver=4.7.4:977
and alot fo load script errors
</pre>代码:
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()
},我已经检查了所有的网络和堆栈溢出,我不能找到这个问题的问题。
发布于 2017-03-09 18:39:56
最好的解决方案是替换html2element代码,并将composer视图中的代码呈现为以下代码
html2element: function(html) {
var attributes = {},
$template;
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());
}
_.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value;
});
this.$el.attr(attributes).html($template.html());
this.setContent();
this.renderContent();
},
render: function() {
var $shortcode_template_el = $('#vc_shortcode-template-' + this.model.get('shortcode'));
if ($shortcode_template_el.is('script')) {
this.html2element(_.template($shortcode_template_el.html()));
} else {
var params = this.model.get('params');
$.ajax({
type: 'POST',
url: window.ajaxurl,
data: {
action: 'wpb_get_element_backend_html',
data_element: this.model.get('shortcode'),
data_width: _.isUndefined(params.width) ? '1/1' : params.width,
_vcnonce: window.vcAdminNonce
},
dataType: 'html',
context: this
}).done(function(html) {
this.html2element(html);
});
}
this.model.view = this;
this.$controls_buttons = this.$el.find('.vc_controls > :first');
return this;
},https://stackoverflow.com/questions/38873828
复制相似问题