views:

30

answers:

1

Hi,

I've been making a jQuery plugin for password boxes. It adds a generate password button and strength indicator to inputs that are passed to it via a jQuery selector.

I'm having an issue with the code on lines 154 & 155 of jquery.password.js inputPassword.position().top. It's not returning the correct position of the input box, so the error message isn't appearing in the correct place.

I think this is probably an issue with inputPassword not being in the correct namespace, or something like that, but I don't fully understand how these things work in javascript... this is my first jQuery plugin.

Thanks

** link removed *

It wasn't namespaces, it was because the object was hidden. So fixed with: if ( inputPassword.is(":visible") ) { positionObject = inputPassword; } else { positionObject = inputPlain; }

A: 

position() returns the offset relative to the parent, however, as the element you're trying to position is positioned absolutely, you might find it works if you use offset() instead.

Edit: inputPassword is hidden whilst you're retrieving the offset()/ position(). From the docs: Note: jQuery does not support getting the offset coordinates of hidden elements.

Matt
Your link to offset is not the correct one. It can be found here. http://api.jquery.com/offset/
rahul
nope, i tried that but it still gets positioned relative the top left of the screen
TonyVipros
@rahul: Oops, thanks.
Matt