Using not() in jQuery to exclude a member of a class

This is just a quick tip I thought I throw out there. We have an application that applies a fade to a .alert class on all its pages. We have 2 pages that need to not fade one particular alert. Here is one way it can be handled.

  1. Add a class of .notfade to the alert that needs to stay put and not fade out:
    <div class="alert alert-info nofade"></div>
  2. Place the following in $().ready(): $(".alert").not(".notfade")fadeOut(7000);

Saving to a database with ColdFusion using jQuery

A commenter asked me how to extend a previous jQuery post to perform the database save via ColdFusion.  It is REALLY easy (and please keep in mind this is meant to be a SIMPLE example, not production code).  From the jQuery side my example only required the following code to ship the data off to ColdFusion:

function fSave(){
you=$("#you").val();
// Try to save
$.get("adduser.cfm?"+"you="+you , function(data){
// Result
alert(data);
window.location=location.href;
});
}

The adduser.cfm page then validates and inserts the data and returns a success or failure message.

See it hereGet it here.

Use jQuery to enable submit button and set form action

I recently had to do a quick bit of coding to only accept data from a form if JavaScript was enabled.

This example starts with a form that has no action and a disabled submit button.  When jQuery’s .ready() fires though it enables the submit button and attaches the appropriate action.

Please note the example file is in ColdFusion so your mileage may vary slightly for your own use.

See it here | Get it here.