Giter Club home page Giter Club logo

jquery-flash-message's Introduction

 jQuery Flash Message plugin

 Copyright (c) 2011 Brandon Calloway
 Licensed under the MIT license:
 http://www.opensource.org/licenses/mit-license.php

Provides Flash Message functionality similar to a Ruby on Rails application, after a CRUD operation.

For example, in an ASP.NET MVC project, you can place the following after a controller action has completed:

	Response.Cookies.Add(new HttpCookie("FlashSuccess", "The page was succesfully created!") { Path = "/" });
	return RedirectToAction("Index");
 
This will create a cookie named "FlashSuccess", and will be read by the $.flashMessage jQuery function.
Additionally, there is a function called flashPrompt that will allow you to use flash messages in ajax success/error callbacks.

Requirements:
   jQuery 1.4.x or higher, http://docs.jquery.com/Downloading_jQuery
   jQuery cookie plugin, http://plugins.jquery.com/project/Cookie

Be sure to include this javascript file after the above requirements, and before any javascript files that use flash messages.

In your main javascript file, include the plugin like so:
	$("#messages").flashMessage();

By default, the flash message looks for the following div container:

	<div id="messages"></div>

If the flash message is a success, it appends a class called "flash-success". If the flash message is an error, it appends a class called "flash-error".
You can style the flash message however you choose in your css.

To use the flashPrompt function to provide an ajax callback:

	flashPrompt('succes/error', 'Whatever you want the message to be');
 
For example:

   $.ajax({
	    url: '/admin/pages/delete',
	    type: "POST",
     traditional: true,
	    data: { 'id': page_id },
	    success: function () {
       flashPrompt('success', 'Page was successfully Deleted!');
       }
   });

jquery-flash-message's People

Contributors

bcalloway avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

tarnagas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.