Thanks for the very quick replies. I've discovered in the meantime that it actually DOES work perfectly fine on Firefox - just not on IE7. These are the two browsers I normally test stuff on. So if it's me, it's only partly me ;-)
I'll try the defer. Thanks again. Cheers Steve On Sep 28, 2:34 pm, "T.J. Crowder" <[email protected]> wrote: > Hi Steve, DJ, > > In my experience usually it *is* there by the time onComplete is > called, but just in case it is a matter of the browser not having > caught it's breath, Steve you can use Function#defer[1] to give the > browser a moment. It may be overkill, but you could even encapsulate > this into a function: > > function focusWithRetry(id, attempts) { > var element; > > element = $(id); > if (element) { > element.focus(); > } > else if (--attempts > 0) { > focusWithRetry.defer(id, attempts); > } > > } > > But I wonder if it may be something else. If #defer doesn't do it, can > you create a minimal failing test case?[2] You may figure it out by > doing that, or if not it'll give folks on the list something to get > mano-a-mano with. > > [1]http://api.prototypejs.org/language/function.html#defer-instance_method > [2]http://proto-scripty.wikidot.com/self-contained-test-page > > HTH, > -- > T.J. Crowder > tj / crowder software / comwww.crowdersoftware.com > > On Sep 28, 7:08 am, DJ Mangus <[email protected]> wrote: > > > If the id 'editdescription' is added to the DOM it won't have been > > processed by the browser OnComplete. You will have to delay the > > function. > > > Sent from my phone so pardon the spelling errors. > > > On Sep 27, 2009, at 10:59 PM, Steve Marshall <[email protected]> > > wrote: > > > > Hi all. I'm brand-new to Prototype - just discovered it yesterday, > > > and I must say it feels like I have come home. It seems to be at just > > > the right level, and it just works (so far). I'm a happy camper! > > > > One minor thing - I tried using an Ajax.Updater, and when it completes > > > I want to set the focus to an entry field, but it isn't working. > > > Here's my Ajax.Updater: > > > > new Ajax.Updater('row'+code, 'svc/ajax.php', { > > > parameters: {action: 'editlibcat', code: catcode}, > > > onComplete: function() {$('editdescription').focus();} > > > }); > > > > This call sets a row in a table into editable form, and there's > > > another Updater that does the update - pretty standard stuff I'd > > > reckon. There definitely IS an element with ID='editdescription' - > > > it's in the HTML that is returned from the Ajax call. But focus never > > > gets set. Everything else is perfect. It must be me - what do I have > > > wrong? > > > > Thanks again for Prototype - it's great! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
