Skip to content

Bug in remove() from $.Model.List class #147

Description

@OnGit

Version: 3.2
Problem: Removing a specific item (eg. the second) from a $.Model.List instance removes always the first item.

Example code:
var list = new $.Model.List([{tag: 'bla1', rating: 1},{tag: 'bla2', rating: 2},{tag: 'bla3', rating: 3}]);
list.remove(list.match('tag', 'bla2'))
The list has now the following content:
[Object { tag= "bla2", rating=2}, Object { tag="bla3", rating=3}]

Quick Solution:

There is something wrong with idetification of the item which has to be removed. The slice operation extracts always the first element instead of the specified one. The following code solves the problem. Replace (at ~ line 512)
if ( inst[idName] == id ) {
with:
if ( jQuery.toJSON(inst) == jQuery.toJSON(args[a]) ) {

I would appreciate if you could have a look at this issue and solve it for the next release.
Thanks and kind regards
Oli

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions