2013-04-16 25 views
2

使用http://www.lukemelia.com/blog/archives/2012/03/10/using-ember-js-with-jquery-ui/我試圖通過Ember.ArrayController加載模板實現一個可排序列表,其中有一個數組作爲內容的電話號碼:當使用jquery-ui排序與ember.js時使用jquery-ui排序更新一個屬性

{{#collection App.SortableListView contentBinding="phonenumbers" itemViewClass="App.SortableItem"}} 
<b>{{phonenumber.cost}}</b> 
{{/collection}} 

我想排序後更新每個PHONENUMBER的「秩序」屬性,但我無法弄清楚如何做到這一點:

App.SortableListView = JQ.SortableListView.extend({ 
    items: 'article', 

    //update is a jquery ui method called when the sort ends and dom has been updated 
    update: function(event, ui) { 
    // I would like to update and persist each phonenumbers model here 
    } 
}); 

我已經試過各種事情:bindAttr在訂單上,通過jQuery的數據屬性,使用內容每個childView的tIndex屬性(但它在排序時不會更新)......一切都失敗了,或者對於這麼簡單的事情來說太複雜了。

我想我錯過了明顯的東西,thx爲您的幫助。

回答

-1

有陣列控制器上您想要

+0

什麼,我相信他是指在jQuery UI的意義上的「排序」(http://jqueryui.com/sortable/),這意味着允許用戶拖動該做sortProperty方法物品按照他們想要的順序。 – CraigTeegarden

+0

@piotr對不起,但這不是問題在這裏。 – Flyingbeaver