mmm*_*tzz 2 javascript ajax wordpress jquery json
我有一些视觉作曲家的问题.由于旧版本无法获得支持.客户不会付钱.问题是我无法在后端添加元素.chrome调试出错:
我试图用代码解决问题:Uncaught TypeError:无法读取undefined的属性'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>
Run Code Online (Sandbox Code Playgroud)
码:
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()
},
Run Code Online (Sandbox Code Playgroud)
我已经检查了整个网络和stackoverflow,我无法找到这个问题的问题.
小智 6
最好的解决方案是将composer视图中的html2element代码和渲染代码替换为以下代码
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;
},
Run Code Online (Sandbox Code Playgroud)
Soruce:https://gist.github.com/maximspokoiny/34ad60ad90944f8a80c6fc093873a807/9fb041d2b12249fe4391f986f4e7e6a08f57c6b3#file-gistfile1-txt
| 归档时间: |
|
| 查看次数: |
3680 次 |
| 最近记录: |