Recent Notes
Displaying keyword search results 1 - 10
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 May 01, 2011 21:57:33
Last update: May 01, 2011 21:57:33
Both visibility:hidden and display:none hides an element in the DOM. But elements with visibility:hidden still takes up space, while display:none does not.
Example (click the divs to hide or show):
<!doctype html>
<html>
<head>
<style t...
Created by James on May 01, 2011 21:40:35
Last update: May 01, 2011 21:47:18
It's a shame that double click events are always accompanied by click events in JavaScript. When you double click on an element, JavaScript fires two click events followed by one double click event. So if you attach both click and double click event handlers to the same element, both event handlers will be called when you double click. This is a utility function to alleviate the problem somewhat:
<!doctype html> <html> <head> <script ... Note that there's still a possibility that both clicks and double clicks fired at the same time. This is because the timer used above may not be identical to the double click timer configured at the OS level. It's impossible to fix this problem in application code since each user may...
Created by James on May 01, 2011 20:46:46
Last update: May 01, 2011 20:46:46
Unlike languages such as Python or PHP, an empty array in JavaScript is true . The proper way to test for an empty array is to check the length attribute:
// empty array is true
var anArray = [];
if ...
Created by James on March 29, 2011 11:37:53
Last update: March 29, 2011 11:37:53
The test page below reports the column and row indexes of the table cell you clicked.
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on March 29, 2011 11:28:33
Last update: March 29, 2011 11:30:12
The test page below shows how to count the number of columns for a given table row with jQuery:
$('table tr:eq('+row+') td').length
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on March 29, 2011 11:25:35
Last update: March 29, 2011 11:25:35
With jQuery, it is pretty easy to access a table cell: just use the $('table tr:eq('+row+') td:eq('+column+')') selector. Below is a test page:
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on March 13, 2011 13:44:37
Last update: March 21, 2011 11:30:55
This is a jQuery input control that lets you enter any number of input rows of name and value pairs.
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by Captain on November 22, 2010 04:34:37
Last update: March 05, 2011 20:42:17
<!DOCTYPE html>
<html>
<head>
<style ...
Reference:
Custom Resolutions on Intel Graphics
Created by James on March 03, 2011 21:48:52
Last update: March 03, 2011 21:48:52
Just another way to left zero-pad a string.
function zeroPad(s, length) {
if (s.length ...