小编Chr*_*ley的帖子

在jQuery UI Sortable之后更新CollectionView内容的最佳方法?

感谢@ ghemton的safeClone方法,我已经能够在Ember.js中运行jQuery UI Sortable :Ember.js + jQuery UI Draggable Clone

一旦排序完成,我很难让Ember知道这个变化.现在,我splice按照将数组元素从一个数组位置移动到另一个数组位置的建议使用,集合中的项目移动到适当的位置.这工作正常,但我有窗口滚动的问题.

在这个jsfiddle,http://jsfiddle.net/chrisconley/g4aE6/,如果你滚动到底部,然后重新排序任何元素,窗口跳回到顶部.如果你把一个断点之间propertyWillChangepropertyDidChange,你可以看到,灰烬从视图瞬间,这是造成窗口跳回到顶端删除所有项目.

App.MySortableView = Em.CollectionView.extend({
  moveItem: function(fromIndex, toIndex){
    var items = this.get('content');
    this.propertyWillChange('content');
    item = items.splice(fromIndex, 1)[0];
    items.splice(toIndex, 0, item);
    this.propertyDidChange('content');
  }
});
Run Code Online (Sandbox Code Playgroud)

有没有办法在没有删除和更换整个集合的情况下通知Ember?

更新方案:

(感谢Christopher Swasey的回答)

App.MySortableView = Em.CollectionView.extend({
  moveItem: function(fromIndex, toIndex){
    var items = this.get('content');
    item = items.objectAt(fromIndex);
    items.removeAt(fromIndex);
    items.insertAt(toIndex, item);
  }
});
Run Code Online (Sandbox Code Playgroud)

这里有完整的例子:http://jsfiddle.net/chrisconley/NN35P/

javascript jquery-ui ember.js

5
推荐指数
1
解决办法
1310
查看次数

有没有办法检查POST网址是否存在?

有没有办法确定POST端点是否存在而没有实际发送POST请求?

对于GET端点,检查404s并不是问题,但我想检查POST端点,而不会触发远程URL上的任何操作.

methods post curl http

2
推荐指数
1
解决办法
1730
查看次数

标签 统计

curl ×1

ember.js ×1

http ×1

javascript ×1

jquery-ui ×1

methods ×1

post ×1