0

ember.js で奇妙な問題に直面しています。つまり、"data-template-name" 属性をスクリプト タグに追加すると、何も機能しません。data-template-name name が削除された場合、問題なく動作しています。

  This is NOT WORKING 
   <script data-template-name="my-template"  type="text/x-handlebars">
    Input: 
    {{#view App.MyView}}
    {{view Ember.TextField 
           valueBinding="view.theValue"        
           placeholder="input ..." }}
    {{/view}}
</script>




  Now if **data-template-name="my-template"** is removed it works fine. 
I mean, In UI  TextField is visible.

  <script   type="text/x-handlebars">
    Input: 
    {{#view App.MyView}}
    {{view Ember.TextField 
           valueBinding="view.theValue"        
           placeholder="input ..." }}
    {{/view}}
</script>




App.MyView = Ember.View.extend({
templateName: 'my-template',
theValue: null,
init: function(){
    this._super();
    this.set('theValue','asdf');
},
keyDown: function(e){
   if(e.keyCode === 13){
        alert(this.get('theValue'));
   }
}

});

4

1 に答える 1

3

わかりました、jsfiddle について心配しないでください。それは良いスタートです :)。Ember.js サイトには、Ember.js 関連のソースを含む開始点を見つけることができるリンクがあります: http://emberjs.com/community/

つまり、このような Ember.js アプリケーションを作成する場合、暗黙的なデフォルトの匿名テンプレートがあり、その中で独自のテンプレートを定義できます。

 <!-- default template, introducing the view App.MyView -->
 <script type="text/x-handlebars">
  {{view App.MyView}}
 </script>

<!-- template of App.View -->
<script data-template-name="my-template"  type="text/x-handlebars">
  Input: 
  {{view Ember.TextField 
         valueBinding="view.theValue"        
         placeholder="input ..."}}
</script>​

javascript:

App.MyView = Ember.View.extend({
  templateName: 'my-template',
  theValue: null,
  init: function(){
    this._super();
    this.set('theValue','asdf');
  }
});​

サンプルの実際の例を次に示します。

http://jsfiddle.net/6p6XJ/171/

于 2012-12-10T21:10:03.487 に答える