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.

TGIT 80/20 Principle Talk

I recently spoke on the 80/20 principle at the spiritual business group TGIT - Thank God It's Thursday http://www.ambica.net/thank_god_its_thursday.html

TGIT is part Book Reading Club, part Support Group and part Mastermind Group that puts us - the participants - in touch with our Deepest Essence through sharing, reflecting on, and applying wisdom from some of the most ancient as well as today's progressive inspirational literature.

The 80/20 Principle says that there is an inbuilt imbalance between inputs and outputs, causes and consequences, and effort and results. Furthermore, a minority of causes, inputs or effort usually lead to a majority of the result, outputs, or rewards. A few things are important; most are not. Most systems have an non-linear imbalance in them where a minority of inputs create a majority of the results. This is caused by the butterfly effect - small fluctuations in seemingly minor events having a big result, similar to chaos theory. Feedback loops keep a system moving in one direction until hitting a tipping point, at which point small efforts make a big difference.

A typical example is the 80/20 relationship where 80% of results come from 20% of effort. The 80/20 numbers here are only a metaphor. The real relationship may be more or less unbalanced than 80/20. The fact that 80 and 20 add up to 100 is a coincidence. The point is that a small amount of input creates a majority of the results. It could be that 5% of your effort creates 70% of the output, or maybe it creates 90%. It is rare for the relationship between input and output to be linear or 50/50. Yet this is the assumption that many people make of all situations - that working an extra hour is worth the same as any other hour already worked.

The 80/20 Principle is inherently optimistic, however. To achieve more with less focus on the 20% of resources that really matter in terms of achievement, and let go of (or delegate) the remaining 80%.

Examples:

* 80% of the bugs come from 20% of the code

* 80% of customer complaints can be eliminated by correcting only 20% of the causes.

* 80% of the benefits will be found in the simplest 20% of the software system.

* Most software spends 80% of its time executing only 20% of the available instructions.

* 80% of memory access is for only 20% of records.

 

To learn more see the book "The 80 / 20 Principle: The Secret to Success" by Richard Koch

OR

Read the Executive Summary by Vadim Kotelnikov.

http://www.1000ventures.com/business_guide/crosscuttings/80-20principle.html

The Mood Cure: The Four Part Mood-Type Questionnaire

Write down the number next to each symptom that you identify with. Total your score in each section and compare it to the cut-off score. If your score is over the cut-off, or if you have only a few of the symptoms described in a section, but they bother you (or those close to you) on a regular basis, turn to the chapter indicated.

 

Part 1: Are You Under a Dark Cloud?

Part 2: Are You Suffering From the Blues?

Part 3: Is Stress Your Problem?

Part 4: Are You Too Sensitive to Life’s Plan?

 

To take the test please visit:

www.moodcure.com/Questionnaire.html

"Worry" is Interest Paid in Advance on Borrowed Trouble - Not Worth Paying!

Have you ever worried about an upcoming phone call, a future presentation, or a pending decision with a client?  Have you ever worried about your performance at a previous meeting or presentation?  Or, perhaps you've fretted over a comment expressed by a client.  If so, you're not alone.  People often worry about past or future events.

 

A small amount of concern--emphasis on small--can be beneficial if it urges you to review your strategy and look for ways to improve.  But, when worry begins to fill your day, it clouds your thinking and diverts your attention from current tasks and real issues to imagined scenarios, which rarely develop, or past events over which you no longer have control.  It obscures your judgment and prevents logical, objective analysis.  Worry is not a healthy emotion, and worrying is not a constructive activity.  


Worrying about future events can be avoided with intelligent organization.  Designate a specific amount of time for planning and preparation for future events.  Then, schedule the time so it doesn't interfere with other normal activities.  Finally, and most importantly, give yourself permission to keep to the schedule...and then LET IT GO!  


Worrying about past events can be avoided by accepting the possibility of a less than perfect outcome.  Sometimes, your undertakings will be carried out flawlessly...exactly as planned, and you'll achieve your desired result.  That's good.  Other times, the outcomes won't be so ideal.  That's not so good, but it is part of the human experience.  ACCEPT IT!  No amount of worrying will change it.


You can further minimize worry by thoughtfully planning your week and then prioritizing and organizing your daily activities.  If today's activities are well organized, you should be able to start tomorrow's activities without worrying about what took place today.  And, if tomorrow's activities are thoughtfully planned, you should be able to complete today's activities without worrying about what will happen tomorrow.

"Do You Sell, Or Do You Tell?": Jack Hauser's Sandler Sales Meeting Minute

Sales people love to talk, especially about the features and benefits of their product or service with which they are in love. Have you ever talked so much and that you actually talked your prospect out of the sale?

 

Have you ever been a prospect and wished the sales person you were with would just shut up? How did you feel when the sales person talked too much? Comfortable? Probably not. Were you listening to the features and benefits? Also, probably not. You knew what you wanted and he or she was telling you what they thought you should know. But, that's probably never been the feeling a prospect of yours has ever had.

 

Remember, people buy from people that they are comfortable with. Selling is asking the right questions, not telling your prospects about features and benefits. You will gain greater trust with your prospect if you Sell, not Tell!

ColdFusion server not so expensive

I often hear one objection to using ColdFusion is that it is necessary to buy the server software.

Good news. Now that ColdFusion is owned by Adobe, companies that have a discount account with Adobe also get a discount on CF server.

I learned this on a discussion list and have not had a chance to verify with Adobe.

ColdFusion MX 7 & MySQL Connection on Windows & Linux

As you know ColdFusion & MySQL connection is a bit tricky. There is a Technote from Adobe. But I also want to give some simple tips.

You can check my simple tutorial via "http://www.howtoforge.com/coldfusion7_mysql4.1_connection".

Restarting Server by ColdFusion

Sometimes we may need to restart our server because of some problems. Specially on windows based servers this would be headache if you have a remote server. Mainly we can use tools like "Terminal Services", "PC Anywhere", or "VNC" etc. But there would be also to reach these interfaces.

I would like to suggest a simple page which may help to restart you server via ColdFusion.

We can use command line as following via CFEXECUTE tag.

view plain print about
1<cfexecute
2    name="C:\Windows\system32\shutdown.exe"
3    arguments="-r -f">

4</cfexecute>

In case of not having "shutdown.exe" in some systems, we can use also IIS to restart the server as following.
view plain print about
1<cfexecute
2    name="C:\Windows\system32\iisreset.exe"
3    arguments="/reboot">

4</cfexecute>

What you can do is put this code somewhere in the server with password protection (of course!) and running them if you need to restart the server.

Getting Java System Information

As you know ColdFusion is based on Java. If we would like to have some more information about using the Java platform we can use the following code.

view plain print about
1<cfset SysJVM = CreateObject("java", "java.lang.System").properties>
2<cfoutput>
3    <cfloop collection="#SysJVM#" item="id">
4        <strong>#id#</strong>: #SysJVM[id]# <br />
5    </cfloop>
6</cfoutput>


What I Do After First Dreamweaver Installation

I have just formatted my drive C after having a new hard disk and installed everything again and again. Of course Dreamweaver is also installed from scratch. After starting Dreamweaver for the first time I need to set some settings. Here is what I do after a new Dreamweaver installation.

  • First I am a ColdFusion/Flex developer and I prefer code environment.

  • Then "Edit-> Preferences" and some "must have" changes.
    • Code Hints: "After typing the open tag's. ">"."
    • New Document: "Default document -> ColdFusion template", "Default encoding -> Unicode", check for "Include Unicode Signature (BOM)".
    • Validator: XHTML 1.0 transitional

  • and some other stuff which are not so important but would be good for me.
    • General: check for "Reopen documents on startup"
    • Code Coloring: ColdFusion (this selection was a bug and do not work on every Dreamweaver installation)
    • Code Format: check for "Automatic wrapping"


  • If you have other initial setup for CF in Dreamweaver, please share with us.

More Entries

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