1

In this fiddle click the blue buttons to select Agents and add them to the list.

I create legend elements to show the Agent's name to the right of the respective input's label. (I do this so that long names don't disturb my table layout. If there's a better way, I'm all ears!)

You can remove Agents from the list by right-clicking on the respective blue button.

In a list of three of more Agents the legends of the Agents moved up (after removing the first Agent), all go to the same place, instead of staying with their respective label elements.

The code responsible for this starts with: if (selectName != "undefined" && selectName) {

I've spent three days on this! Please help me understand what I'm doing wrong.

Also, how do I prevent the need for two clicks to do anything after using the right-click to remove an Agent?

Thank you

Chris

cneeds
  • 319
  • 3
  • 13
  • I've not understend... what happen in the fiddle code? If i click right mouse button on blue button the agent will be removed... – Alex Ball Aug 13 '12 at 11:19
  • @Alex, sure. Add four or more agents and remove the second one and you will see the error. Chris (I have edited my question.) – cneeds Aug 13 '12 at 11:25
  • Ah ok... You must increment the position of css top, in your loop the ptop is the same for all and the label will be overwriting. Check with: `ptop = position.top + ptop;` should resolve your question. – Alex Ball Aug 13 '12 at 11:41
  • @Alex, you are correct but ptop should get the position of the next label down the list but I can't see why it doesn't. Adding ptop again doesn't resolve this. Chris – cneeds Aug 13 '12 at 12:02
  • Hi check [this](http://jsfiddle.net/alex_ball/gV8qU/36/) updated fiddle, is not fully correct but could be an step to resolve it. – Alex Ball Aug 13 '12 at 12:37
  • @Alex. Cool, if I add 6px to h (h+6) the vertical position of each legend is "more correct". Thank you. It wasn't the answer I had hoped for but it will be a usable workaround in the interim, until the day when I fully understand why my version doesn't work. Do you have any ideas on the second part of my question (Also, how do I prevent the need for two clicks to do anything after using the right-click to remove an Agent?), please...! Thank you for your help. Chris (How do I give you +1 for this?) – cneeds Aug 13 '12 at 13:00
  • The second part is not clear for me but if you want avoid the contextmenu by right click there are many discussion about it like [this](http://stackoverflow.com/questions/706655/bind-event-to-right-mouse-click) for example. No problem for the +1, I'm happy to be usefulf ;-) – Alex Ball Aug 13 '12 at 13:21

0 Answers0