[ 3 posts ]

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

problem calling destroy() inside ModelList .each method

Post Posted: Thu May 31, 2012 2:39 am
+0-
I doubt this is an issue related to Model and ModelList but more likely an error in my coding, can anyone help.

I have a model list and calling each on the list to access each model, and then calling destroy on the item results in every other item being skipped, I guess this is because this list size is constently changing. This is what I am trying to do:

modelList.getRelated("relationship").each(

function(item,index) {

item.destroy(
{},
function(e) {
if(!e) {
Y.ModelStore.unregisterModel(item);
} else {
console.log(e);
}
});});

What would the correct way to do this be? Do I first need to extrapolate the models unique id into an array and iterate over this array to access the models instead?

Thanks for any guidance

Richard.

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Re: problem calling destroy() inside ModelList .each method

Post Posted: Thu May 31, 2012 10:53 am
+0-
was this a dumb question? I know there are obvious ways to do this, I guess I was just looking for some confirmation best practices.

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: problem calling destroy() inside ModelList .each method

Post Posted: Wed Jun 06, 2012 9:08 am
+0-
You're right, it is an issue; luckily it has already been identified and fixed:
http://yuilibrary.com/projects/yui3/ticket/2531910

This fix will show up in 3.6.0 and it is already in 3.6.0pr1.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum