-1

I want to send flash messages to views in total.js and i see an alternative approach with use of query string and check that flag for know what to show in view:

in controller:

this.redirect('/?success=1');

and in related view:

@{if query.success}
    //proper message
@{fi}

but i want to know is there any other approach available to show any status (error or success) messages?

Pourya8366
  • 3,424
  • 4
  • 21
  • 28

1 Answers1

1

In some cases I use same approach but I recommend to do it on client-side via JavaScript if it's possible and my next recommendation is to send all forms via AJAX, always. Less code on server-side brings more benefits:

  • less CPU and memory consuption on server-side
  • output of view can be cached
  • better performance
  • smaller transmission data

Here is a Flash module with same functionality as in Express.js, but I don't recommend it: https://github.com/totaljs/modules/tree/master/Miscellaneous/flash

For rendering some flash messages you can use controller.repository object or model or you can create some View Engine Helper. There are many ways how to do it.

Peter Sirka
  • 748
  • 5
  • 10