Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OnGit opened this issue Jan 13, 2013 · 0 comments
Open

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

OnGit opened this issue Jan 13, 2013 · 0 comments

Comments

@OnGit
Copy link

OnGit commented Jan 13, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant