Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27019 > unrolled thread

set/get a data attribute, for loop closure prob

Started byJRough <janis.rough@gmail.com>
First post2015-03-11 20:32 -0700
Last post2015-03-13 09:47 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  set/get a data attribute,  for loop closure prob JRough <janis.rough@gmail.com> - 2015-03-11 20:32 -0700
    Re: set/get a data attribute,  for loop closure prob "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-03-13 02:58 +0100
    Re: set/get a data attribute,  for loop closure prob JRough <janis.rough@gmail.com> - 2015-03-13 09:47 -0700

#27019 — set/get a data attribute, for loop closure prob

FromJRough <janis.rough@gmail.com>
Date2015-03-11 20:32 -0700
Subjectset/get a data attribute, for loop closure prob
Message-ID<d01ca00f-f84a-4d29-a94b-bd42426addbc@googlegroups.com>
I have a jsfiddle,  http://jsfiddle.net/jlrough/wq95ycr5/
the images are missing but  I can tell you what it is doing.  If you click the previous or next  links it moves the carousel image forward or backward okay.  

The problem is when you do the hover.  Whichever dot you hover on it makes all the images go forward to the end instead of stopping on the one you hover on.

The error I'm trying to fix is the For loop which is a closure.  The hover function should not get the value of i from the For loop.  So as a hack to solve it I tried to put the value of i in a data attribute.    However it doesn't seem like my data method is setting or getting the data attribute.   TIA,

[toc] | [next] | [standalone]


#27021

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2015-03-13 02:58 +0100
Message-ID<mdtg7s$338$1@solani.org>
In reply to#27019
JRough wrote:

> I have a jsfiddle,  http://jsfiddle.net/jlrough/wq95ycr5/
> the images are missing but  I can tell you what it is doing.  If you click the previous or next  links it moves the carousel image forward or backward okay.  
> 
> The problem is when you do the hover.  Whichever dot you hover on it makes all the images go forward to the end instead of stopping on the one you hover on.
> 
> The error I'm trying to fix is the For loop which is a closure.  The hover function should not get the value of i from the For loop.  So as a hack to solve it I tried to put the value of i in a data attribute.    However it doesn't seem like my data method is setting or getting the data attribute.   TIA,

Just a quick note.  Don't use this:

  for (var i = 0; i < $('.carousel-dots-nav-item').length; i++) {

but *rather* something like:

  $(".carousel-dots-nav-item").each(...)

That should solve your binding issues.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#27022

FromJRough <janis.rough@gmail.com>
Date2015-03-13 09:47 -0700
Message-ID<6f1436f8-6be9-4050-9870-cab278fba547@googlegroups.com>
In reply to#27019
On Wednesday, March 11, 2015 at 8:32:35 PM UTC-7, JRough wrote:
> I have a jsfiddle,  http://jsfiddle.net/jlrough/wq95ycr5/
> the images are missing but  I can tell you what it is doing.  If you click the previous or next  links it moves the carousel image forward or backward okay.  
> 
> The problem is when you do the hover.  Whichever dot you hover on it makes all the images go forward to the end instead of stopping on the one you hover on.
> 
> The error I'm trying to fix is the For loop which is a closure.  The hover function should not get the value of i from the For loop.  So as a hack to solve it I tried to put the value of i in a data attribute.    However it doesn't seem like my data method is setting or getting the data attribute.   TIA,

thanks it was supposed to be easy but I couldn't see it.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web