javascript - 将 jquery-ui 与 ember.js 一起使用时更新 ArrayController 模型中的属性

标签 javascript jquery-ui ember.js

使用 http://www.lukemelia.com/blog/archives/2012/03/10/using-ember-js-with-jquery-ui/我正在尝试在由 Ember.ArrayController 加载的模板中实现一个可排序列表,该模板包含一个电话号码数组作为内容:

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

我试图在排序后更新每个电话号码的“顺序”属性,但我不知道该怎么做:

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
  }
});

我尝试了各种方法:按顺序绑定(bind)属性,通过 jquery 的数据属性,使用每个 childView 的 contentIndex 属性(但在排序时它没有更新)...一切都失败了,或者对于这样一个简单的事情来说太复杂了。

我想我遗漏了一些明显的东西,感谢您的帮助。

最佳答案

数组 Controller 上有 sortProperty 方法可以做你想做的事

关于javascript - 将 jquery-ui 与 ember.js 一起使用时更新 ArrayController 模型中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16041672/

相关文章:

javascript - 通过ajax将PHP对象返回给javascript

javascript - 当编辑器在对话框之前创建时,CKEditor 4 在 jquery 对话框中损坏

asp.net - 用于 DataTypeCheck 的 jQuery UI datetimepicker 和 ASP.NET CompareValidator

jquery-ui 自动完成组合框更改跟踪

ember.js - 从后端接收更新数据后索引 View 不刷新

javascript - Ember.TextField 从组件内部定位 View

javascript - jQuery "slideDown"动画不起作用

javascript - 当 Angular 7 中该 url 的资源文件夹中没有 img 时,如何处理错误 404

javascript - 在 WebStorm 中更改 JSX 代码样式

javascript - 使用 concat 助手渲染组件