Hi everyone,
I am using the following to remove items from an array i am building up. Users add items to the array and may need to remove them too, it all works ok, except when we get to the last element.
this is part of an object, hence the "this.lines" to identify the array.
It appears to simply fail when you effectively call
I can see why this might be the right thing if there is only one element in the array, but it causes problems when there are several items in the array and it is the first that needs to be removed.
Any suggestions?
Thanks.
I am using the following to remove items from an array i am building up. Users add items to the array and may need to remove them too, it all works ok, except when we get to the last element.
Code:
function removeLine(id){
if(id == ''){
return;
}
this.lines.splice(id,1);
}
this is part of an object, hence the "this.lines" to identify the array.
It appears to simply fail when you effectively call
Code:
this.lines.splice(0,1);
I can see why this might be the right thing if there is only one element in the array, but it causes problems when there are several items in the array and it is the first that needs to be removed.
Any suggestions?
Thanks.