> Using cocoon 2.1.8, here is the problem:
>
> Say a form has a repeater with many rows. If there is a repeater-action
> at the bottom that adds a new row, clicking it causes a form submit, and
> the user ends up at the top of the page, where the new row sits at the
> bottom of the page.
>
> Likewise, if the repeater rows themselves have nested repeaters, any
> action that causes a form submission leaves the user at the top of the
> page, in a different "context", if you will, than where they performed
> the "submit action".
>
> Is it possible, without ajax, to have a page submission target the
> widget that was "acted upon"?
>
> Is CForms able to output an <a name="repeteater-row-id"> that is
> targeted somehow via an http://my_continuation_url#repeater-row-id?

You don't need an <a name=""> element to implement anchors, any element
with an id attribute will do, and is in fact the preferred method since
HTML4.  All HTML fields produced by CForms already have an id attribute,
so you should be able to use that.

Perhaps you can add an onclick handler to your button that adds the id of
that button to the end of the form action as a fragment identifier before
submitting:

  onclick="this.form.action += '#' + this.id;"

Unfortunately the styling XSLT already adds an onclick to buttons, so you
may have to override the appropriate template(s) to add your custom
onclick.

Or another approach might be to override the built-in submitForm JS
function, by adding something like the following to your own JS that gets
loaded after the base cforms.js:

  cocoon.forms._orig_submitForm = cocoon.forms.submitForm;
  cocoon.forms.submitForm = function(element, name) {
    var form = this.getForm(element);
    form.action += '#' + element.id;
    this._orig_submitForm(element, name);
  }

(Based on cforms.js in 2.1.8, assumes the JS API doesn't change.)  This
would add the fragment identifier for all form submits, which may be what
you want or maybe not.

Hope that helps
--Jason



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to