bcalloway / jquery-flash-message Goto Github PK
View Code? Open in Web Editor NEWA simple jQuery plugin to add Rails-like flash messages
A simple jQuery plugin to add Rails-like flash messages
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!'); } });
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.