2016-05-07 5 views
3

ホスティングプロバイダが自動的に4.5にアップデートされ、Visual Composerプラグインでエラーが発生しました。Wordpressアップデート後のプラグインエラー

は、私はこれらの記事を読みました: Plugin throwing TypeError after Wordpress 4.5 update

Visual composer doesn't load and gives TypeError: _.template(...).trim is not a function

Uncaught TypeError: $template.get is not a function

そして提供1と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 

誰かがそれを修正する方法を考え出しましたか?あなたの助け

答えて

17

は、4.5アップデートで同じ問題を抱えていたし、私が見つけたすべてのものを試してみましたが、それ:

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

へまだ動作していませんでした。

最後に、テーマビジュアルコンポーザープラグイン(v4.7のもの)を最近のもの(4.11.2、google js_composer.zip)に置き換えました。

私はちょうどディレクトリの内容全体を置き換え、それは正常に動作します。

+0

完全に働いた –

+0

ありがとう、それは – Cagdas

+0

あなたは人生の節約になります! – Amir

4

グラハム、ハイテク

ため

おかげで、私はjs_composerで使用していることではないjqueryのではなく、アンダースコアで問題だと思います。

で、このようなhtml2elementメソッドにメソッドパス間違ったHTMLオブジェクトをレンダリング:

this.html2element(_.template($shortcode_template_el.html(), 
      this.model.toJSON(), 
      vc.templateOptions.default)); 

しかし、このコードは、任意のプロパティまたは何か他のものを持っていない機能の方法のHTMLオブジェクトをhtml2elementに送信します。これは、アンダースコアライブラリの_.template関数が最初のargの有効な変数を持たない2番目のargの前に最初のarg(htmlテンプレート)を表示しないために起こります。この問題を解決するための私の意見で

がこれを行う必要が:

this.html2element(_.template($shortcode_template_el.html())); 

をこの2つの方法は私がjs_composer 4.7.4とワードプレス4.5.2を使用して、これで問題が解決しhttps://gist.github.com/maximspokoiny/34ad60ad90944f8a80c6fc093873a807/9fb041d2b12249fe4391f986f4e7e6a08f57c6b3#file-gistfile1-txt

をレンダリングしてhtml2element。

ありがとうございます!

更新日: 申し訳ありませんが、html2elementにする必要があまりにも1つの変更、から:

  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()); 
     } 
+2

これは「ちょっと」動作します。要素を編集できますが、要素を追加することはできません。 – bestprogrammerintheworld

関連する問題