[Seaside] Modal dialogs and Updating/closing
johan at inceptive.be
Sun Mar 29 16:03:49 UTC 2015
> On 12 Mar 2015, at 11:22, Torsten Bergmann <astares at gmx.de> wrote:
> I have a modal dialog in Seaside like the Bootstrap one demonstrated
> When I click on "Save Changes" I would like the server to verify
> data (for instance check credentials for a login) and possibly
> display a message in the dialog when the input was wrong.
> In such a case I only want to refresh the contents of the dialog
> and not a full page refresh, because with a full page refresh the
> dialog would not be open again but also I want the updated info
> to look smooth without flickering of a full page reload.
> Also when the data is fine after checking on the server the
> dialog should close.
> What options do I have/whats the best way to implement this?
> Any best practices or simple examples ideally with Bootstrap?
The issue here is that when you push the button in the modal dialog, you should already know if it will be a full page request or an ajax request. Because you don’t know that yet, you can only perform an ajax request that returns a script to either perform the full page request, or adds the error message to the dialog:
onClick:((html jQuery ajax)
script: [ :s | self showErrorMessage ifTrue: [ s << (self scriptForErrorMessageOn: s) ] ifFalse:[ s << (self scriptOnSuccessOn: s) ] ]);
The script to show the error message would be a ‘normal’ jquery script that appends some html somewhere (this is application specific).
The script to perform the full page request can be built in Seaside as follows:
More information about the seaside