summary-of-event-response.go 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. package advanced_functions
  2. import (
  3. "github.com/qor5/docs/docsrc/generated"
  4. . "github.com/theplant/docgo"
  5. "github.com/theplant/docgo/ch"
  6. )
  7. var SummaryOfEventResponse = Doc(
  8. Markdown(`
  9. The behaviour of ~web.EventFunc~ is controlled by it's return type ~web.EventResponse~
  10. `),
  11. ch.Code(generated.EventResponseDefinition).Language("go"),
  12. Markdown(`
  13. - ~PageTitle~ set the html head title, It not only set when render html page directly which is
  14. request the url directly from the browser. Also use javascript to set the page title when you do
  15. push state AJAX request to load the page
  16. - ~Body~ is the set to ~web.PageResponse~'s body when ~Reload = true~ is set, Or set to the partial
  17. html component when using ~ReloadPortals~ together with ~web.Portal().EventFunc("related")~
  18. - ~Reload~ is to reload the ~web.PageFunc~, before reload, you can set ~ctx.Flash~ object to let the
  19. event func render the page differently (flash message, validation errors, etc)
  20. - ~Location~ is to change the browser url with push state, and AJAX load the page of that url
  21. - ~RedirectURL~ is to change the browser url without AJAX, reload the whole page html includes it's
  22. head script, css assets
  23. - ~ReloadPortals~ is for reload the portal that uses ~web.Portal().EventFunc("related")~
  24. - ~UpdatePortals~ update the portal specified by the name ~web.Portal().Name("hello")~, ~pu.AfterLoaded~
  25. set the javascript function that execute after the portal is updated, for example:
  26. ~VarsScript: "setTimeout(function(){ comp.vars.drawer2 = true }, 100)"~
  27. - ~Data~ is for any AJAX call that want pure JSON, you can set ~er.Data = myobj~ to any object that
  28. will marshals to JSON, and on the client side use javascript to utilize them
  29. `),
  30. ).Title("Summary of Event Response").
  31. Slug("basics/summary-of-event-response")