Friday, December 30, 2011
Inspect all jQuery events on an element
$("SELECTOR").data("events");
All bound event handlers are stored in the elements data context under the events key
This can be very useful when debugging with tools like FireBug
$("form").submit(function () { alert('submit form'); });
$("form").data("events");
> Object { submit=[1] }
Resources
Tuesday, March 15, 2011
asp mvc jquery from cdn with fallback to localhost
For asp mvc you usually also want jquery.valdiater and possibly unobtrusive validation as well. Here is an html helper to generate html mark up that handles loading these via cdn with fallback
The helper
Usage, most likely from your layout file
And the rendered html
Friday, October 22, 2010
jQuery iframe auto height plugin
Download from github
http://github.com/house9/jquery-iframe-auto-height
see the README file for usage
Thursday, May 27, 2010
jsfiddle is awesome!
Friday, September 25, 2009
Attribute "target" exists, but can not be used for this element.
Attribute "target" exists, but can not be used for this element.
Resources
Friday, August 21, 2009
Ajax error handling with ruby on rails and jquery
This sample is just a slight modification of this post 'Handling AJAX errors and displaying friendly error messages to users'. Basically I wanted to maintain the existing rails error handling for non-ajax pages and then have good handling for errors in both development and production mode; i.e. get errors in the browser when in development mode and show a nice message when in production mode.
Modify /app/controllers/application.rb; add the rescue_from macro and the handler_exception method
Then add a global javascript method for presenting the errors; most likely in application.js
Then a sample usage, jquery making an ajax post to a rails controller action
in development mode the error message is returned in an easier to read view in the firebug console and an alert message is presented that has a truncated version of the error

in production mode just a friendly error message.

Resources
- Handling AJAX errors and displaying friendly error messages to users
- Rails source code rescue.rb
- Rails views source on your install lib/action_controller/templates/rescues
- jquery ajax
Monday, March 2, 2009
jqueryUI effect error with Google Chrome and Safari
Using a slightly modified version of the demo. I tweak the background image before applying the highlight effect
$("#highlight").click(function() {
$(this).css("background", "url(some_image.png) no-repeat");
$(this).effect("highlight");
});
$(this).css("background-image", "url(some_image.png)");
$(this).css("background-repeat", "no-repeat");
$(this).effect("highlight");
Monday, February 16, 2009
use jquery to disable a button when clicked
NOTE: the above code snippets are untested - cut, pasted and modified from real code that was tested (and worked!)