Recent Notes
Displaying keyword search results 1 - 10
Created by James on September 18, 2012 12:14:13
Last update: September 18, 2012 20:28:46
This is an example of IIFE (Immediately Invoked Function Expression) from jQuery Plugins Authoring :
(function( $ ) {
$.fn.myPlugin = function() {...
Created by James on May 03, 2012 14:54:46
Last update: May 03, 2012 14:54:46
History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. For HTML4 browsers it will revert back to using the old onhashchange functionality. All major browsers are supported.
This is a simple test page to get started:
<html>
<head>
<title>Test History</title>
...
Note: state url must be provided for IE to generate a unique hash. YOu can prefix the state url with '?' ('#' does not work).
Created by James on April 24, 2012 13:50:05
Last update: April 24, 2012 13:50:05
The this object can be changed when calling a JavaScript function with func.call(theObject) . This is an example:
<!DOCTYPE html>
<html>
<head>
<title>jQu...
The JavaScript console logs:
[Global log] this is: [object Window]
[log.cal...
Created by James on June 22, 2010 18:56:40
Last update: February 13, 2012 10:25:47
Version 1.6.4:
<!-- jQuery -->
<script type="text/javascript" ...
Version 1.7.1:
<script type="text/javascript" src="https://ajax.g...
Google URL: http://code.google.com/apis/ajaxlibs/documentation/#jquery
Created by James on February 02, 2012 09:20:22
Last update: February 02, 2012 09:20:22
This example came from the jQuery validation documentation. The required rule can be used to validate a required selection box when you set the value of the first option to empty.
<!DOCTYPE HTML>
<html>
<head>
<scrip...
The error message is the title since no error message is specified. A more fully defined validation check would look like this:
$('#my-form').validate({
errorElement: "p",
...
Created by James on January 30, 2012 10:39:33
Last update: January 30, 2012 10:39:33
The qTip tooltip hides when mouse is off the target but on the tooltip itself. This makes it hard to click links in the tooltip - when you try to click the link, it disappears. Add the " fixed: true " flag to prevent it from disppearing:
<script type="text/javascript">
$(function() {
...
Created by Fang on January 16, 2012 19:32:20
Last update: January 16, 2012 19:32:54
You can submit a form via Ajax by the jQuery Form Plugin . There are two main methods:
ajaxForm : prepares a form for Ajax submit.
Example:
$('#myFormId').ajaxForm({
target: ...
When the form is submitted, it is sent via Ajax.
ajaxSubmit : submit a form via Ajax.
Example:
$('#myForm2').submit(function() {
// i...
jQuery Form Plugin is not in the core jQuery API, so you have to include an additional JS file:
<head>
<script type="text/javascript" ...
Created by Fang on November 28, 2011 21:04:15
Last update: November 28, 2011 21:04:15
Some innocent looking JavaScript may cause a fatal error in a Facelet page. For example:
<script type="text/javascript">
if (items.lengt...
or
<script type="text/javascript">
// jQuery code ...
Because Facelet is strict XML, therefore, < and > must be escaped.
There are several ways to deal with this:
Do not embed JS code directly in the page. Put the code in .js files and include it in the page with the src attribute.
Put JS code in a CDATA section:
<h:outputScript target="head">
<![CDATA...
Use XML entities:
<script type="text/javascript">
// jQuery code ...
Created by James on November 27, 2011 16:02:11
Last update: November 27, 2011 16:02:11
This is an example that uses the XSLTProcessor jQuery plugin for client side XSLT. Unfortunately it didn't work in IE or Chrome. It worked in Firefox but somehow disable-output-escaping="yes" was ignored.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/...
Created by James on September 23, 2010 20:30:55
Last update: November 16, 2011 14:51:23
jQuery button set where one button can be pressed "down" at a time.
<!DOCTYPE html>
<html>
<head>
<title>jQu...