2

I am trying to understand how the integration between jQueryUI and Emberjs should be done. I am new to both libs and to javascript so this might be a newbie question.
I have this jsfiddle set up: http://jsfiddle.net/pSKgV/1/ and it renders this resulting document:

<body class="ember-application">  
    <div id="ember129" class="ember-view">  
        <div id="ember163" class="ember-view ui-draggable"></div>  
    </div>  
</body>

The code is mostly taken from this blog post: http://www.lukemelia.com/blog/archives/2012/03/10/using-ember-js-with-jquery-ui/

Questions: How do I put something inside the inner div? I want to put some content that i can bind to something. I have tried the following: {{view App.Draggable}}Drag Me{{/view}} but that gives an error. I’ve also tried adding this to the App.Draggable object:

didInsertElement: function() {  
     this.$().html(“Drag Me”)  
     }  

but that did not give the expected results. How is the best way to use/access the jquery/jqueryui functions such as .html() in this situation?
Also, is the outer div necessary or can I make this view only render one div element?

regards Oskar

4

1 回答 1

4

http://jsfiddle.net/ud3323/XMgwV/

您忘记了 # 符号{{#view App.Draggable}}Drag me{{/view}}。您还应该在 Ember 中创建命名空间,Ember.Namespace.create()而不是只使用一个空的{}

于 2012-04-28T15:33:28.517 回答