[Seaside] Complex popup with JQuery

Esteban A. Maringolo emaringolo at gmail.com
Mon Mar 19 13:08:01 UTC 2018


2018-03-17 4:12 GMT-03:00 jtuchel at objektfabrik.de <jtuchel at objektfabrik.de>:
> Bruno,
>
> if you do a
>
> (html ajax callback: ()) onComplete:(html jQuery: idOfRootCompForRedraw)
> load html: [html render: rootComponentForRedraw]
>
> (not tested, just from my head)

The "fixed" version would be something like this:

onClick: ((html jQuery ajax callback: ["..."]) onComplete: (
                 (html jQuery id: idOfRootCompForRedraw)
                   load html: [:h | h render: rootComponentForRedraw]))

Another alternative is to execute the callback within a script
response, saving one extra HTTP roundtrip for the "onComplete".

onClick: (html jQuery ajax script: [:s |
                "your callback actions".
                (html jQuery id: idOfRootCompForRedraw) html: [:h | h
render: rootComponentForRedraw]
               ])

> this should redraw the complete subtree of rootComponentForRedraw. If this
> component is inside your popup, the popup will be redrawn. So you do do
> both: just redraw individual components or redraw complex component trees.

I managed to get a similar behavior using Bootstrap's Popover plugin
<https://getbootstrap.com/docs/3.3/javascript/#popovers>, where the
popover is dynamically attached and its content is loaded from the
server once opened (so you get an "updated" content every time you
open it).

> One thind to keep in mind, however, is that you need to be careful when
> using forms in popups. A Form will only submit its own contents, and it
> will redraw the whole page. So forms with submitbuttons etc. are a no-go
> for popups, or you need to work some JS magic around that.

Submit buttons cause a full page reload, unless you handle the submit
event and return false at the end.
Why I do these days is submit almost everything using
#serializeChildren: on the form, triggered by a button or anchor that
IS NOT a submit button.

There are a lot of "recipes" like this that we should share in the
Seaside wiki or somewhere.

Regards,


More information about the seaside mailing list