0

I'm creating a "Contacts" form similar to Google Contacts (and the iPhone "new contact" setup) and I need a similar JS solution. The functionality will be very similar in that I want to have standard fields for Email, Phone, Fax, etc ... but once inputed you have the option to designate it as Home, Work, Mobile, etc and are given the option to add an additional entry.

I know this is probably a shot in the dark, but is anyone familiar with a solution online that accomplishes this? TIA

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Ryan Grush
  • 2,076
  • 3
  • 37
  • 64

1 Answers1

1

It looks like your basic problem is your focusout handler; if you delete it then everything works (except that then your contact type UI hangs around). I would recommend either:

A) making the focusout handler check its e.target, and if e.target is the div with the contact types, return false (then clear the contact type options after that click event resolves)

B) use a different mechanism to clear the contact type options

machineghost
  • 33,529
  • 30
  • 159
  • 234
  • I think this is the issue you're referring to http://stackoverflow.com/questions/11424465/keep-div-and-its-children-in-focus-until-focus-out-of-div. This has caused mucho headaches, but unfortunately seems necessary. I have the 1st part of the process down (showing and switching from the phone/email type), integrating the next part though (adding a new entry field) is making my head spin. – Ryan Grush Jul 16 '12 at 23:31
  • Heh, didn't know there was an SO about it, but yeah that seems about right. However, your comment doesn't match your JSFiddle; the fiddle makes it look like the focusout is your problem, but if your comment is correct and you've solved that part, you really should update your fiddle. – machineghost Jul 16 '12 at 23:40
  • I posted that SO last week ;) Had to resolve it with some 'tabindex' magic on the parent div. The JSfiddle is the up-to-date version I have so maybe I'm a little confused as to the focus-out issue you're referring to. Are you talking about the 'undefined' error thats showing up? – Ryan Grush Jul 16 '12 at 23:44
  • I had no knowledge of that other SO post whatsoever. 23 minutes ago you linked jsfiddle.net/nosfan1019/MVRrs. When I go to that fiddle, click in to an input, then try to click on a contact type, the contact type option goes away. Since your original question didn't make clear what your actual problem was, I assumed that was it (and thus, that's what my answer addresses). – machineghost Jul 16 '12 at 23:47
  • Weird, I'm not having that issue. What browser are you running? – Ryan Grush Jul 16 '12 at 23:49
  • Yeah thats the problem. UHHH, one more issue to resolve – Ryan Grush Jul 16 '12 at 23:52
  • works on Chrome for some reason – Ryan Grush Jul 16 '12 at 23:53
  • Huh; well, in any case let this be a lesson on asking more specific questions in your SO posts: if you don't silly people like myself will answer the wrong question ;-) – machineghost Jul 16 '12 at 23:58
  • Thought I was clear enough, sorry :/ Thanks for your help though – Ryan Grush Jul 17 '12 at 00:01