-
-
Save levantoan/519bb0d42c9f7bd6c4d78ef1686bb848 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
Find html2element in | |
Version < 4.8: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js | |
Version > 4.9: wp-content/plugins/js_composer/assets/js/dist/backend-actions.min.js | |
*/ | |
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) { // **errors on this line** | |
attributes[attr.name] = attr.value; | |
}); | |
this.$el.attr(attributes).html($template.html()); | |
this.setContent(); | |
this.renderContent(); | |
}, | |
/* | |
Then replace to function | |
*/ | |
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() | |
}, | |
/*by http://levantoan.com/cach-sua-loi-uncaught-typeerror-template-get-not-function-cua-plugin-visual-composer-khi-update-wordpress-len-4-5/*/ |
Noticed that code was not being passed into the html2element function, but did exist in the function calling it (render)
The following code has completely corrected my problems, I can load the page, add, clone, remove, etc
render: function () { var $shortcode_template_el = $( '#vc_shortcode-template-' + this.model.get( 'shortcode' ) ); if ( $shortcode_template_el.is( 'script' ) ) { var newHtmlCode = _.template( $shortcode_template_el.html(), this.model.toJSON(), vc.templateOptions.default ); if(!_.isString(newHtmlCode)){ newHtmlCode = $shortcode_template_el.html(); } this.html2element( newHtmlCode ); } 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; },
It works, thank @amritoshpandey
This was really helpful...replacing htmlelement worked for me
Works. Only needed to change render function from @amritoshpandey. Original html2element function did not need to be changed.