Contact Us Today!   |   + 1 (301) 424 3903



18 JQuery tips

Jo Ann shared these JQuery tips after CFUnited this year. Enjoy!

PS What are your JQuery tips?

  1. Syntax:  The dollar sign ($) is an alias for the jQuery object.
  2. Best documentation (online reference) is:   http://docs.jquery.com/   [www.visualjquery.com, which I have used, is only up to version 1.2.6 (and the current release is 1.3.2)]
  3. OK to call the $(document).ready() function as many times as you want on the same page.  They will execute in turn; they don't overwrite each other.  This is in direct contrast to the more traditional body onload attribute, where it is NOT OK to use more that one definition. If you add 2 definitions for body onload, the 2nd overwrites the first, and the first is never executed.
  4. In JavaScript, the Function IS a datatype.  This is very important in jQuery, because many jQuery methods take functions as parameters.
  5. Named functions:  doSomething(param1, param2) { [some action statements in here]; }  If I set myVar1 = doSomething("foo","bar"); then myVar1 contains the RESULT of doing something with "foo" and "bar".  But if I set myVar2 = doSomething;     (i.e., without the parens) now myVar2 IS the same function as doSomething.  Now myVar2("foo","bar"); will return the same thing as doSomething("foo","bar");  This concept can be useful if you need to pass functions to a method that takes one or more Functions as arguments.
  6. An Anonymous Function in JavaScript is a Function declaration without a name.  For example, $(document).ready() takes as an argument a Function that receives the ready event as an argument.  Typically instead of declaring a named function and putting the name inside the ready() parens, you put ready(function(event){ [what to do goes in here]; })
  7. Can use jQuery to intercept a button click or other event, do some validation or manipulation with information on the page, and submit a hidden form instead of ever giving the user direct access to the form inputs.  Also for CFFORM augmentation - for example to grab the error messages and log them, to do some analysis before submission, to visually magnify the field with incorrect input so the user can see it better to verify.
  8. Can overload existing JavaScript functions.  For example, overloading alert() could make the standard CF-generated validation messages display in a nicer alternative appearance and style.
  9. Syntax: .attr('[attribute_name]') is a getter, and .attr('[attribute_name],'[value]'') is a setter.
  10. Syntax: the filter  :eq(3)  gets the 3rd element of a set, while  :nth(3)  gets EVERY 3rd (i.e., 3, 6, 9, 12 ...)
  11. A filter such as  :last  is applied to the selected / returned SET of elements - so 'li:last'  gets the last <li> element on the page, NOT the last item in EACH list on the page.
  12. Syntax: A space in a selector (example '#list2 li:last') means get all of the 2nd selector that are descendants of the element(s) returned by the first selector (as opposed to separating with > which signifies "direct children" instead).
  13. Utilities are jQuery methods without selectors [examples:     $.each()   or   $.support()   ]
  14. How people create compressed and obfuscated JaveScript files: jsmin utility to strip out extraneous white space, yuicompressor to obfuscate by replacing variable names with something less easy to understand.  (However, JS is always still out in the world for everyone to see!)
  15. jQuery UI is the only jQuery plugin created by jQuery itself.  Use Theme Roller: http://jqueryui.com/themeroller/  to create custom UI themes (try out and style the various UI elements).
  16. http://layout.jquery-dev.net  - look at Layout Inside Dialog
  17. Syntax tip: parseInt('30px') takes the 30 out of '30px'
  18. Can use jQuery along with CF-generated JavaScript validation, for instance to enable/disable/re-enable CF validation in response to a browser-side event of some kind.

Can Spiral Web predict the future of Web 2.0?

I am speaking on “Spiral Web – the future of web society” at the Web 2.0 conference in Virginia on November 1st 2007. The talk will look at what is coming in the next year for the web? What about in the next five years? How can we predict trends in websites? Spiral web provides both insight into existing websites and predicts future trends in websites. Based on the long established theory of spiral dynamics for human society development, Spiral Web explains and predicts the evolution of web societies. More information at http://cfunited.com/blog/index.cfm/2007/9/20/Web-20-for-Business-Conference

Do you need to tap the wisdom of crowds?

Companies know that you know what you want. Interactive Web 2.0 technologies are now enabling
businesses to use their customers to lead product design, create content and solve problems.
“Crowdsourcing”, which allows people to take part in online discussions and vote on what the company
should be doing, is already starting to take off.

Dell's IdeaStorm web site, launched last year, lets members post, discuss and vote on suggestions.
The decision to offer PCs with the Linux operating system pre-installed came from a proposal on the
site – and took less than three months from concept to launch. As crowdsourcing gains traction, it
will no longer be used just by large firms. It will be used by emerging companies and federal
agencies as a way to solve problems faster to tap the wisdom of crowds.

You can read more in James Surowiecki' s book "the Wisdom of Crowds" or see him live at the Web 2.0 conference

Is Mahalo manual search engine web 3.0 or web -1.0?

I read about a new search engine called Mahalo ("thank you" in Hawaiian) in Fast Company.

Is it using some fancy algorithm to beat Google or more powerful servers to power
the search? No. Mahalo uses people to do the searching. At first it seems kind of web -1.0
but perhaps there is something to it. After all people are much harder to be
fooled by spammers. And people are still better at computers figuring out
what search results are really useful. Does getting 100,000,000 search results
really help me or do I want just one page of personally honed results?

Mahalo staff pre-write responses to the most popular search terms. They
only target the top 30%, or about 15,000 terms. The rest get refered back
to Google. Mahalo will be a search engine for people who don't like to
search. Maybe this is Web 3.0. Hmmm.

http://www.fastcompany.com/magazine/118/man-vs-machine.html

 

 

BlogCFC was created by Raymond Camden. This blog is running version 5.9.8.012. Contact Blog Owner