Skip to main content

JS and HTML to support the Django contrib.messages app

Project description

jQuery messages-UI plugin package for Django

django-messages-ui adds JS and HTML to support the Django contrib.messages app. It should be called on the message list element, and accepts options for message selectors, transient messages (that disappear on click or key-press), and close-links.

Messages can be dynamically added via ICanHaz.js, and there’s a Python middleware to automatically add messages from the request into Ajax JSON responses.

Dependencies

Installation

In your Django project settings, add “messages_ui” to your INSTALLED_APPS.

Usage

Linking the JS:

<script src="{{ STATIC_URL }}messages_ui/jquery.messages-ui.js"></script>

Including the default HTML Template:

{% include "messages_ui/_messages.html" %}

Calling the plugin:

$('#messages').messages();

Calling the plugin with a variety of options explicitly configured to their default values:

$('#messages').messages({
    message: '.message',          // Selector for individual messages
    closeLink: '.close',          // Selector for link to close message
    transientMessage: '.success', // Selector for transient messages
    transientDelay: 500,          // Transient message fade delay (ms)
    transientFadeSpeed: 3000,     // Transient message fade speed (ms)
    handleAjax: false             // Enable automatic AJAX handling
});

Adding a message in JS (requires ICanHaz.js):

$(ich.message({message: "Sample Message", tags: "info"}).appendTo(
    $('#messages'));

To override the default JS template, add a message.html file to a directory listed in your ICANHAZ_DIRS setting (a django-icanhaz setting).

Ajax

To enable automatic handling of messages from Ajax requests, add "messages_ui.middleware.AjaxMessagesMiddleware" to your MIDDLEWARE_CLASSES setting (directly after django.contrib.messages.middleware.MessageMiddleware), and pass handleAjax: true to the plugin initialization.

CHANGES

0.1.2 (2011.06.27)

  • Added AjaxMessagesMiddleware and handleAjax plugin option.

0.1.1 (2011.06.27)

  • Updated HTML template (removed <aside> and moved #messages to <ul>).

0.1.0 (2011.06.25)

  • Initial release.

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-messages-ui-0.1.2.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file django-messages-ui-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-messages-ui-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6a34783e5cdc42e044c59f0750d6fd0b96e1e456400daac8f3ef4b117b60e95a
MD5 ee873d4fe0dbf29709e1f2f3ab61a751
BLAKE2b-256 20cee351857bef235d6adb40ce15b74276193b32ce497b74456b950299160b15

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page