Sorry, I misread the change in code and the comments you added. Doing: newZ2 = zindexlt2-2; Would place all windows that were previously above the window you just brought to front on the same z-index, which I don't want. The reason for the newZ2--; is that all above it go down one level, and then the one that was clicked jumps to the very top of all of them. This allows for all windows above it to go down one, so they all stay on separate levels, but in the same order.
On Nov 14, 9:03 am, ricardobeat <[EMAIL PROTECTED]> wrote: > I haven't looked througly at your code, but I see you're using global > variables, that might be an issue: > > $('.draggableWindow').mousedown(function(){ > var numWindows=$('.draggableWindow').length + 500; > var zindexIt2 = parseInt($(this).css("z-index")); > if(zindexIt2 < numWindows){ > $(this).css("z-index",numWindows); > $('.draggableWindow').each(function(){ > var newZ2=$(this).css("z-index"); > if(newZ2 > zindexIt2){ //being greater > doesn't mean it's only 1 unit greater > newZ2 = zindexlt2-2; //just to be safe > $(this).css("z-index",newZ2); > $(this).children('h1').text(parseInt($ > (this).css("z-index"))); > } > }); > } > }); > > On Nov 14, 11:13 am, CodingCyborg <[EMAIL PROTECTED]> wrote: > > > jQuery('.draggableWindow').mousedown(function(){ > > numWindows=jQuery('.draggableWindow').size() + 500; > > zindexIt2 = parseInt($(this).css("z-index")); > > if(zindexIt2 < numWindows){ > > $(this).css("z-index",numWindows); > > $('.draggableWindow').each(function(){ > > newZ2=$(this).css("z-index"); > > if(newZ2 > zindexIt2){ > > newZ2--; > > $(this).css("z-index",newZ2); > > > > $(this).children('h1').text(parseInt($(this).css("z-index"))); > > } > > }); > > } > > }); > > > I added a line so I could watch the z-index movements of the draggable > > windows. I found that they are all on separate layers but for some > > reason instead of each of them above the one you bring to front > > dropping one, some will drop two while others don't move. I'm not sure > > why this is happening, it's almost as if some windows are run through > > the .each() multiple times while others don't move. Or when others go > > through it they affect the first one through it. > > > Help would be highly appreciated! > > > On Nov 13, 1:08 pm, CodingCyborg <[EMAIL PROTECTED]> wrote: > > > > I recently have been playing around with a "Desktop" module that was > > > on nettuts and made a modification for it that doesn't fully work. > > > There are many draggable windows, and in order for them to function > > > like a real desktop they need to have z-index changes such that if you > > > close one on top the last one you had on top is right below it. > > > > I believe my error comes in with "this" or possibly something else, > > > but when you pull one to the front it causes some or all of the others > > > to end up in the same z-index causing them to not stay in order of > > > recently viewed. > > > > jQuery('.draggableWindow').mousedown(function(){ > > > numWindows=jQuery('.draggableWindow').size() + 500;//the > > > + 500 is to > > > make sure they are above other objects on the page > > > zindexIt2 = parseInt($(this).css("z-index")); > > > if(zindexIt2 < numWindows){ > > > $(this).css("z-index",numWindows);//brings to > > > front > > > $('.draggableWindow').each(function(){//supposed > > > to drop others > > > back one... > > > newZ2=$(this).css("z-index"); > > > if(newZ2 > zindexIt2){ > > > newZ2--; > > > $(this).css("z-index",newZ2); > > > } > > > }); > > > } > > > });