emberjs template compile doesn't work in rc1

眉间皱痕 提交于 2019-12-24 19:31:53

问题


I have

Esploreo.TE.Views.ItemView = Ember.View.extend({
    elementId : "item",
    templateName : 'itemTemplate'
});

and a template like

<script type="text/x-handlebars" data-template-name="itemTemplate">
  content of templat
</script>

and all works good. But i don't to want to use this type of coding. In previous Ember versions it was possible to write the template code in the definition of view, like this:

Esploreo.TE.Views.ItemView = Ember.View.extend({
    elementId : "item",
    template: Em.Handlebars.compile('content of template'),
});

but it doesn't work (emberjs 1.0.0-RC.1). This features is removed from this release?


回答1:


That's a curious way of working with Ember! To answer your question though, you need to add .append() to the end of your .create() like so:

App.ItemView.create().append();

Obligatory jsFiddle: http://jsfiddle.net/MGXDe/

Whilst I don't know your use case for this, I can't stress enough that this seems a little too curious, bordering on bad usage of Ember.



来源:https://stackoverflow.com/questions/14984207/emberjs-template-compile-doesnt-work-in-rc1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!