1

コレクション内の最後のモデルを削除するにはどうすればよいですか?

      if (this.Collection.models.length < newValue) {
        console.log('adding');
        this.Collection.models.add();
      } else {
        console.log('removing');
        // this isnt working, by selecting it by the current collection array index
        // basically this.Collection.remove([this.Collection.models.length-1])
        //this.measuresCollection.models.get('beats').remove(this.measuresCollection.models[i].get('beats')[this.measuresCollection.models[i].get('beats').length]);
      }

IDがわからないので、最後のIDだけ削除したいです。

4

1 に答える 1

6

collection.pop([options])

ドキュメント: Collection#pop .

ドキュメントの remove メソッドの下にあります。最後のモデルを削除し、必要に応じて元に戻します。単に削除したい場合は、戻り値を使用しないでください。

于 2013-04-09T18:37:14.927 に答える