Uncaught TypeError: $template.get is not a function

后端 未结 8 1293
遥遥无期
遥遥无期 2020-12-24 01:28

I am getting this error in WordPress when I am using a plugin called WpBakery Visual Composer.

I am using the latest version of WordPress (4.5), using the latest Go

8条回答
  •  盖世英雄少女心
    2020-12-24 01:40

    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;
    		},

提交回复
热议问题