Skip to content

Web2py plugin for manage message in the view using the toast library.

License

Notifications You must be signed in to change notification settings

jorgelhd94/toast_message_web2py_plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Web2py Toast Message Plugin

This is a Web2py plugin for manage messages in the views using the toast library. To install the plugin it is necessary to use the web2py plugin manager.

Requirements

  1. Use Boostrap 4 library in the layout
  2. Include web2py_ajax.html file in the layout

Function plugin_toastr_message_config()

plugin_toastr_message_config('type_message', 'message_text', ajax=False)

Function arguments

  • type_message(string): Define the message css style. Can be:

    • success: Show a success message

    • error: Show an error message

  • message_text(string): Define the message text.

  • ajax(bool): Used when working with web2py ajax components. Allows the message to be displayed asynchronously:

    • Important: In case of using the messages in an asynchronous controller and using the response.js variable, it is necessary to call the plugin_toastr_message_config() method after the last use of the response.js variable.

Usage

After installing the plugin in the web2py plugin manager it is necessary to add a few lines of code in the main layout.

  1. Add the next code to view/layout.html (the main layout) into the body tag (preferably last):
  • {{=plugin_toastr_message()}}
  • <div id="plugin-toastr-message"></div>
  1. To launch the message, include the next code in a controller.

plugin_toastr_message_config('success', 'All good', ajax=False)

ok

Or

plugin_toastr_message_config('error', 'Oops!! An error has occurred!', ajax=False)

error

Contributors

Many thanks to Ronald William Pérez Sánchez for his help.

About

Web2py plugin for manage message in the view using the toast library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published