Recent Notes

Displaying keyword search results 1 - 10
Created by James on April 25, 2012 08:38:05    Last update: April 25, 2012 08:38:05
With no parameters, the .toggle() method simply toggles the visibility of elements. Example: $(function() { $('body').click(function() { ...
Created by James on February 02, 2012 09:31:03    Last update: February 02, 2012 09:31:03
This is an example that adds a validation rule to jQuery validation: // add a custom method $.validator.addMethod("m...
Created by James on March 11, 2011 08:53:31    Last update: January 30, 2012 09:33:56
Both delegate and live allow you to bind event handlers to elements created in the future, but there are some differences: For .delegate , the event bubbles up to the element on which it is called. For .live , the event bubbles up to the root of the DOM tree, or, as of jQuery 1.4, optionally stop at a DOM element context. DOM traversal methods are not supported for finding elements to send to .live() . Rather, the .live() method should always be called directly after a selector. The opposite of .live is .die . The opposite of .delegate is .undelegate . Note: As of jQuery 1.7, the .live() method is deprecated . Use .on() to attach event handlers. Users of older versions of jQuery...
Created by Fang on January 16, 2012 19:50:00    Last update: January 16, 2012 19:50:00
jQuery validation plugin hooks into the form submission cycle, so in order to submit a form via Ajax you have to use the submitHandler option of the validate method: $('#myform').validate({ submitHandler: func... Or, with jQuery Form Plugin: $('#myform').validate({ submitHandler: func...
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 January 16, 2012 15:34:15    Last update: January 16, 2012 15:34:15
Use the .serialize() method to encode the form data for Ajax call: $.ajax({ url: 'formHandler', data: $(t...
Created by James on October 25, 2011 19:44:30    Last update: October 25, 2011 19:45:40
jQuery automatically maps HTML5 custom data attributes to data storage associated with the data() method. Here's an example: <html> <head> <script type="text/javascript"...
Created by jinx on May 04, 2011 20:01:08    Last update: May 04, 2011 20:02:59
A static variable in PHP functions and methods keeps its value after the function/method scope is exited, just like static variables in C. A static variable in a class is a class variable, and is accessed by the class name. In the global scope, static has no special meaning. test.php: <?php include("test.inc"); include("... test.inc: <?php static $i = 0; $i++; echo __FILE__,... Output: E:\phpwork\test.inc included: 1 E:\phpwork\test...
Created by jinx on April 29, 2011 15:03:10    Last update: April 29, 2011 15:04:02
The PHP function is_callable verifies that a variable can be invoked as a function. Example: <?php define('F', 'f'); function... Output: var_dump: string(1) "f" is_callable: 1 Calla...
Created by jinx on April 25, 2011 12:43:40    Last update: April 25, 2011 12:43:40
Use the PHP function method_exists to check if the class or object has a certain method. It returns TRUE if the method exists (even when the value of the property is NULL), FALSE if the method does not exist. Example: <?php class A { var $p = 'A property'; ... Outputs: Class A has method f1: bool(true) Object $a has... Also note that C++-like method overloading does not exist in PHP. Thus there's no ambiguity about which version of the method exists, i.e., with no argument, with one argument... etc. The following code generates Fatal error: <?php class A { var $p = 'A property'; ...
Previous  1 2 3 Next