Notes: Things covered in jQuery section

I’ve realised I am never going to remember this stuff if I don’t take some notes. The act of taking notes and summarising puts the information more securely in to my head.

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

To use jquery you need to either load a file locally or call global version. Script needs to be added in head section.







Two versions on the Google library 1.x and 2.x. If use 2.x has more features but computers with older versions may not understand and therefore may not work (all depends on people updating). Using google version can speed up your site since people may already have it in their cache.

Things covered in this section of the course

Detecting a click. When click change content, change the style, fading content, animating content.

Loading data with AJAX

AJAX = Asynchronous JavaScript and XML. In short; AJAX is about loading data in the background and display it on the webpage, without reloading the whole page. Examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook tabs.

The important thing I learnt is that you cannot run AJAX locally and you need to either use the script for the library version of jquery or have it loaded in the same directory as the files that you are using it with.

Regular Expressions

A regular expression is a sequence of characters that forms a search pattern. When you search for data in a text, you can use this search pattern to describe what you are searching for. A regular expression can be a single character, or a more complicated pattern. Regular expressions can be used to perform all types of text search and text replace operations.
For Syntax see: http://www.w3schools.com/js/js_regexp.asp

Validation of input data in forms

In particular how to find code snippets to use for specific things such as validation of email addresses – don’t need to reinvent the wheel, find code to grab.
eg http://stackoverflow.com/questions/2855865/jquery-regex-validation-of-e-mail-address

jQuery UI = JQuery User Interface

Plugins to make moveable objects and other useful widgets. Available from http://jqueryui.com/
Need to embed just like with jquery – add script at top of page

Interactions

  • Draggable
  • Droppable
  • Resizable
  • Selectable
  • Sortable

Made a square draggable (Lecture 126) – looked at the draggable atributes that can be added – nicely demonstrated with the relevant code for each action.

If you want to find the code to insert at the top search for “jquery ui CDN” (= Content Delivery Network)

For resizable also need to UI style sheet:

Tried out Droppable and change the colour of the target box.
Watched the Sortable and Accordian (widget) options. Then spent time just looking at all of the examples on the jqueryui.com site

Widgets

  • Accordian – Displays collapsible content panels for presenting information in a limited amount of space
  • Autocomplete
  • Button
  • Datepicker – Select a date from a popup or inline calendar (lots of options and variations – interesting to play with)
  • Dialog
  • Menu
  • Progressbar
  • Selectmenu
  • Slider – Drag a handle to select a numeric value.
  • Spinner
  • Tabs
  • Tooltip

Useful links:

Google hosted libraries https://developers.google.com/speed/libraries/
jQuery Learning Centre – http://learn.jquery.com/
jQuery Quick API Reference – http://oscarotero.com/jquery/
jQuery cheat sheet – http://www.javascripttoolbox.com/jquery/cheatsheet/
Another jQuery cheat sheet – http://jqapi.ru/
jQuery Tutorial – http://www.w3schools.com/jQuery/

Footnote: I haven’t finished the section yet there is still at 50 minute project video to do which will take several hours with pausing I feel, so for another day.

You may also like...

Leave a Reply