0

I'm trying to fix this scrollable problem, using this:

var divs = $(".wrap > .outerDiv");
for(var i = 0; i < divs.length; i+=3) {
  divs.slice(i, i+3).wrapAll("<div class='breakpoint'></div>");
}

which is creating a breakpoint while my childs are more than 3.

The only one way to fix it is wrapping 3 childs. Could you double check why dosn't create 3 divs please take a look at my demo.

 <div class="breakpoint">
        <div></div>
        <div></div>
        <div></div>
   </div>

Demo http://jsfiddle.net/2mby5/98/

DD77
  • 1,079
  • 1
  • 12
  • 25
  • It's very unclear what exactly you're trying to achieve. Your chances of getting an answer are better if you either clarify your problem better here or create a fiddle which is cut down to the code relevant to this problem in specific. People very rarely bother to read through a whole lot of code and try to understand it. I did and was still not able to figure out what you are trying to do. – Armatus Apr 17 '12 at 11:18
  • @Armatus thanks, I know is the quite confusing. even to me actually:-). I need to make this to scroll using (wrapAll) and generating the divs properly. – DD77 Apr 17 '12 at 11:43

1 Answers1

0

When your code runs the length of $(".wrap").children() is 1.

If you want it to insert breakpoints after cloning you need to make it fire again (after each clone, I suppose).

Consider a pub / sub for this to make it loosely coupled, there is a good one at https://gist.github.com/661855

primavera133
  • 1,204
  • 1
  • 14
  • 22
  • I've never used this. I know I need to fire it again. would nice some help if you could. – DD77 Apr 17 '12 at 11:41