[pmwiki-users] best way to change editform per view?

Patrick R. Michaud pmichaud at pobox.com
Thu Aug 18 21:53:37 CDT 2005

On Thu, Aug 18, 2005 at 02:54:59PM -0700, H. Fox wrote:
> On 8/18/05, Bronwyn Boltwood <arndis at gmail.com> wrote:
> > Another thing that I really want is that when I hit preview on the
> > editform, PmWiki will jump to the preview section for me.  How can I
> > arrange that?
> That would be nice, but I don't think it can be done.

Thinking about it some more, there might be a couple of ways
to do it, but they're a bit icky and tricky.

The basic problem is that the preview button has to be a submit button
for the edit form, and the url that the browser goes to is in the
<form> element (which would therefore have to have the #preview
anchor at the time the preview button is pressed).  Unfortunately,
we don't always want the browser to jump to a preview section
whenever the form is submitted;  save+edit and simultaneous
edit conflicts should probably not jump to the preview.

So, we need some trickery here.  I have three ideas:

1.  "Jumping anchors."  In this case the url in the <form> tag
always has an anchor in it (e.g., "...wiki/Group/PageName#focus"), 
so the browser will always jump to the #focus anchor, but on
each submit the #focus anchor moves around depending on where
the browser focus should be after the submit.

2.  "Javascript window positioning."  I think there's a way in 
Javascript to tell a browser to position its scrollbar at a certain 
anchor, so we just have the preview output include some javascript
that moves directly to the preview section.

3.  "Submit button mangling."  We might be able to add an
"onclick=" attribute to the preview button that changes the
target of the <form> to include an anchor just before submitting.

None of these are terribly pretty, but they're the best I can come
up with so far.


More information about the pmwiki-users mailing list