Hmm... I see your point (that'll teach me to next time read the code I
add stuff to before emailing).  In theory this check should be working:
  if (arguments.length > 1) {
    Event.stop(arguments[0]);
  }
However, it doesn't (in Firefox and IE on windows).  If you do this:
  alert(Object.inspect(arguments));
You'll see that for some reason the "arguments" var isn't filled in
(like it should be for a normal function).  This might be an artifact of
some JS weirdness because of the bindAsEventListener... I don't know -
doesn't really make sense to me.  The point is that it doesn't seem to
work.

Anyway, if you do this instead, it does work (remove that arguments
check, add in the suggestion made in previous emails):
  enterEditMode: function(evt) {
    if (this.saving) return;
    if (this.editing) return;
    this.editing = true;
    this.onEnterEditMode();
    if (this.options.externalControl) {
      Element.hide(this.options.externalControl);
    }
    Element.hide(this.element);
    this.form = this.getForm();
    this.element.parentNode.insertBefore(this.form, this.element);
    Field.focus(this.editField);
    // stop the event to avoid a page refresh in Safari
    if(evt) Event.stop(evt);
  },
That worked perfectly for me in Firefox and IE on Windows.  By
"perfectly" I mean that it didn't scroll to the top at any point).  I
haven't tried that on my Mac yet.

For completeness, anyone got ideas on why the standard arguments var
check doesn't work?

Rahul

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jon
Tirsen
Sent: Wednesday, October 26, 2005 8:04 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] InPlaceEditor scrolls to top in Firefox?

Unfortunately this fix doesn't seem to work at all. :-( The code was
already stopping the event and even when I return false from the
function it still scrolls to the top. We're back to square one.

:-(

Cheers,
Jon

On 10/26/05, Jon Tirsen <[EMAIL PROTECTED]> wrote:
> On 10/26/05, Rahul Bhargava <[EMAIL PROTECTED]> wrote:
> >
> > 1) have an argument so that the event can be passed into the method
(this is
> > what bindAsEventListener lets you do)
> >
> >   enterEditMode: function(evt) {
>
> You're correct, but sometimes enterEditMode is called without the
> event argument (from the unit tests for example). So we need to
> conditionally stop it if it's not null, like this:
>
> if(evt) Event.stop(evt);
>
> I'll incorporate this in a patch and send it to Thomas asap.
>
> Thanks for the help everyone!
>
> Cheers,
> Jon
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to