在特定索引处插入新元素-同位素Jquery

问题描述

有什么方法可以在不使用排序的情况下在特定索引处插入新元素?例如,假设我们有一个像这样的函数-isotope('insertAtIndex',elem,4),同位素将在布局的第5个位置插入新元素'elem'。

我尝试基于'prepended'函数创建我的自定义函数,但这只会破坏布局。

Isotope.prototype.insertAtIndex = function( elems,index ) {
    var items = this._itemize( elems );
    if ( !items.length ) {
        return;
    }
    // add items to beginning of collection
    var previousItems1 = this.items.slice(0,index);
    var previousItems2 = this.items.slice(index);
    this.items = previousItems1.concat(items).concat(previousItems2);
    // start new layout
    this._resetLayout();
    this._manageStamps();
    // layout new stuff without transition
    var filteredItems = this._filterRevealAdded( items );
    // layout previous items
    this.layoutItems( previousItems1 );
    this.layoutItems( previousItems2 );
    // add to filteredItems
    this.filteredItems = filteredItems.concat( this.filteredItems );
};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...