2012-09-20 4 views
1

Ember.js 샘플 todo app 내의보기를 크기를 조정할 수 있도록한다고 가정합니다.Ember보기에 JQuery UI 옵션 추가

JQuery와 코드는이 될 것이라고해야 할 일 :

$("#container").resizable() 

은 #container는 사업부를 나타냅니다. 나는 앱 스 니펫이 어디에서 속할 것인지 잘 모르겠습니다. app.js 내부로 이동합니까? 내용은 아래에 나열되어 내가 위의 조각을 넣어 가장 적절한 것 어떤 방법을 모르겠습니다. 당신이 이와 같은 DOM 조작 플러그인 다루고있는 보통

Todos = Ember.Application.create(); 

Todos.Todo = Ember.Object.extend({ 
    title: null, 
    isDone: false 
}); 

Todos.todosController = Ember.ArrayController.create({ 
    content: [], 

    createTodo: function(title) { 
    var todo = Todos.Todo.create({ title: title }); 
    this.pushObject(todo); 
    }, 

    clearCompletedTodos: function() { 
    this.filterProperty('isDone', true).forEach(this.removeObject, this); 
    }, 

    remaining: function() { 
    return this.filterProperty('isDone', false).get('length'); 
    }.property('@each.isDone'), 

    isEmpty: function() { 
    return this.get('length') === 0; 
    }.property('length'), 

    allAreDone: function(key, value) { 
    if (arguments.length === 2) { 
     this.setEach('isDone', value); 

     return value; 
    } else { 
     return !this.get('isEmpty') && this.everyProperty('isDone', true); 
    } 
    }.property('@each.isDone') 
}); 

Todos.CreateTodoView = Ember.TextField.extend({ 
    insertNewline: function() { 
    var value = this.get('value'); 

    if (value) { 
     Todos.todosController.createTodo(value); 
     this.set('value', ''); 
    } 
    } 
}); 

Todos.MainView = Ember.View.extend({ 
    templateName: 'main_view' 
}); 

답변

2

, 나는 그것을 추가 할 view의 didInsertElement 메소드에서, this.$()은 views 요소를 나타내는 jQuery 오브젝트입니다. 그런데

Todos.MainView = Ember.View.extend({ 
    templateName: 'main_view', 
    didInsertElement: function(){ 
    this._super(); 
    this.$().resizable(); 
    } 
}); 

, 즉 왜 그렇게 예는 https://github.com/emberjs/examples/tree/master/todos로 대체하고, 심지어 매우 유효 기간이 경과되었습니다.

+0

이 변경 사항은 todos 소스에 적용 할 때 뷰의 일부가 렌더링되지 않아 나에게 적합하지 않습니다. –

관련 문제