last day (14 days later) » 

12:05 PM
0
Q: Attaching Window Resize event to each element saparately

John SmithI've been trying to figure out how, can I attach a Windows Resize event separately to each element (these elements are appended dynamically by PHP via ajax invoke). This is a fiddle that illustrates a little bit, that it's inline modification of positions (left, right, bottom, and top). http:/...

 
The positioning must follow along on window resize.
I already have!
position = $('#' + id).find('a.btnPrimary').offset(); I get the offset and then I use css('top', position.top + 28).css('left', position.left - 208) to position exactly below a button, however, on window resize this continues to work. But if I have two open in my code, only the last opened gets selected due to the global variable id.
@Alex Do you know how to attach events separately to each element? Especially a Window Resize event to keep position.
 
Your fiddle and screenshot are useless. No elements with class btnPrimary and popover in them. Don't stick your question to 'how to bind resize to elements' (maybe thats not the sollution). Instead show us what you have and describe clearly what you want to achieve.
 
@MIvanIsten This is a fiddle that illustrates a little bit, that it's inline modification of positions (left, right, bottom, and top). The screenshot shows what I am trying to achieve.
 
That 'little bit' is a problem. In your fiddle is no js at all, no link with class 'btnPrimary', nothing with class 'popover'. Your fiddle does nothing. There is nothing we can fix on it.
 
@MIvanIsten There's nothing to fix so, the problem is, that I want to know how to attach an event e.g. Window Resize and adjust positions for absolute elements.
 
12:05 PM
There is no element.on('window resize') only element.on('resize'). You are on wrong way. Thats way I wrote my first comment.
 
I am using, $(window).resize to modify the left position inline with css() jquery
Welcome to chat
However, that doesn't help out much, as I already know how to do that. What I want to know, is how to on Window Resize adjust each absolute positioned elements left position. So while the Window is resizing, for each element that has been appended via ajax invoke to PHP it shall adjust the left position on the fly.
Hahahahaha! I found the problem my friend.
 
Gratz. :)
 
12:24 PM
It had to do with the PHP and the id it assigned to the element, so all three elements have the same ID. That makes sense. So I modified the ID inline and realized the .each() method works.
 
12:43 PM
The id on elements should be unique (there should not be more than one element with the same id). If you want identify a group of elements, use class.
 

last day (14 days later) »