Arc Forumnew | comments | leaders | submitlogin
repage: replace only parts of the page when a link is clicked
7 points by almkglor 6109 days ago | 1 comment
New on arc-wiki.git - lib/repage.arc

Often you find yourself designing a web page where the most common actions are immediately displayed, but further actions (more rarely used) are accessed by clicking on a link. Alternatively, an action may require confirmation - for example, to verify if a blog post is to be deleted.

Most of the time, you want to display almost exactly the same page, but with the options expanded, or with a confirmation box. By using (repage ...), you can.

To use, just capture the page you want to display in a (repage ...) form. Then, set the parts you want to replace with (repage-point) forms.

For example, if you want to create some actions:

  (repage
   (generate-content)
   (tag b (prn "Actions: "))
   (w/bars
    (link "commonaction1")
    (link "commonaction2")
    ; generate the "more >>" link
    (repage-point
      (repage-link "more >>"
        ; gets expanded iff the link is pressed
        (w/bars
          (link "rareaction1")
          (link "rareaction2")
          (repage-back-link "less <<"))))))
The current version does not work as expected when doing (repage-point (repage-link "foo" (repage-point (repage-link "bar" (prn "bar"))))). I'm attempting to explain why currently in the source although my explanation could be wrong.


4 points by almkglor 6109 days ago | link

This can obviously be made to additionally generate some ecmascript code to make it ajaxian if the browser has ecmascript enabled

-----