2014-09-26 83 views
0

不知道塊助手是正確的名字,但希望你明白了。把手幫助塊裏面的引號

在餘燼1.8.0-beta.2我不能這樣做

<img src="{{url}}"> 

鉻給我:

Uncaught TypeError: Cannot read property 'parentNode' of null
Uncaught TypeError: Cannot set property 'profileNode' of undefined

和Firefox給我:

TypeError: ref is null
var parent = ref.parentNode;

的錯誤出現來自vendor.js

hydrateMorphs: function() { 
    var childViews = this.childViews; 
    var el = this._element; 
    for (var i=0,l=childViews.length; i<l; i++) { 
     var childView = childViews[i]; 
     var ref = el.querySelector('#morph-'+i); 
     var parent = ref.parentNode; // This line 

     childView._morph = this.dom.insertMorphBefore(parent, ref); 
     parent.removeChild(ref); 
    } 
    } 

我知道我只是可以做一個把手幫手來輸出img標籤與正確的src,但我希望能夠使用{{url}}設置divs背景屬性。
(url屬性只是一個簡化版本,在我的應用程序中,我有一個幫助程序,它需要一個圖像數組和maxWidth來根據寬度給我最好的圖片,但{{url}}也不起作用)

回答

1

忘了,我正好可以利用綁定:

<img src="{{unbound url}}"> 
0

你不能在ember句柄中使用該語法。接受的是bind-attr

使用示例:http://emberjs.com/guides/templates/binding-element-attributes/

更多信息:http://www.emberist.com/2012/04/06/bind-and-bindattr.html

+1

但是,我們在1.8.0測試版1的變化? 「刪除metamorph有利於變形包(不需要DOM中的

  • 11. 如果來自定製幫助程序的幫助程序調用把手
  • 12. 把手內環路助手
  • 13. PHP幫助在這裏創建分頁頁面新手
  • 14. 如何訪問自定義Ember把手幫手的塊內容?
  • 15. CoffeeScript的類和把手模板和自定義塊幫手
  • 16. 幫助有裏面的tableview複選框
  • 17. 在HAML中搞砸的把手塊助手
  • 18. 手風琴+和 - 符號幫助
  • 19. Rails/HAML:image_tag裏面的link_to幫手
  • 20. 單引號裏面雙引號php
  • 21. Javascript,Jquery裏面的Rails助手
  • 22. 車把幫手的JSdoc doclet
  • 23. SQL Server將索引幫助這裏
  • 24. 把手塊幫手「如果」不起作用
  • 25. 刪除文件助手中的引號
  • 26. 把手 - 獲取塊
  • 27. 把手條件塊
  • 28. 帖子在fpdf裏面...幫助
  • 29. 流星助手:在幫助
  • 30. 把手鍊接到與引導導航欄幫手