JQuery and bxp

From All n One's bxp software Wixi

Jump to: navigation, search

jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. jQuery is the most popular JavaScript library in use today, with installation on 65% of the top 10 million highest-trafficked sites on the Web. jQuery is free, open-source software licensed under the MIT License. Microsoft and Nokia bundle jQuery on their platforms. Microsoft includes it with Visual Studio for use within Microsoft's ASP.NET AJAX framework and ASP.NET MVC Framework while Nokia has integrated it into the Web Run-Time widget development platform. jQuery has also been used in MediaWiki since version 1.16. Overview

jQuery, at its core, is a DOM manipulation library. The DOM is a tree-structure representation of all the elements of a web-page and jQuery simplifies the syntax for finding, selecting, and manipulating these DOM elements. For example, jQuery can be used for finding an element in the document with a certain property, changing one or more of its attributes, or making it respond to an event . jQuery also provides a paradigm for event handling that goes beyond basic DOM element selection and manipulation. The event assignment and the event callback function definition are done in a single step in a single location in the code. jQuery also aims to incorporate other highly used JavaScript functionality .

1 Advantages

1.1 The advantages of using jQuery are

  • Encourages separation of JavaScript and HTML: The jQuery library provides simple syntax for adding event handlers to the DOM using JavaScript, rather than adding HTML event attributes to call JavaScript functions. Thus, it encourages developers to completely separate JavaScript code from HTML markup.
  • Brevity and clarity: jQuery promotes brevity and clarity with features like chainable functions and shorthand function names.
  • Eliminates cross-browser incompatibilities: The JavaScript engines of different browsers differ slightly so JavaScript code that works for one browser may not work for another. Like other JavaScript toolkits, jQuery handles all these cross-browser inconsistencies and provides a consistent interface that works across different browsers.
  • Extensible: New events, elements, and methods can be easily added and then reused as a plugin.

2 Features

2.1 jQuery includes the following features

  • DOM element selections using the multi-browser open source selector engine Sizzle, a spin-off of the jQuery project
  • DOM manipulation based on CSS selectors that uses elements' names and attributes, such as id and class, as criteria to select nodes in the DOM
  • Events
  • Effects and animations
  • AJAX
  • Deferred and Promise objects to control asynchronous processing
  • JSON parsing
  • Extensibility through plug-ins
  • Utilities, such as feature detection
  • Compatibility methods that are natively available in modern browsers but need fall backs for older ones, such as inArray and each
  • Multi-browser support
  • Browser support
  • Both versions 1.x and 2.x of jQuery support "current-1 versions" of Firefox, Google Chrome, Safari, and Opera. Version 1.x also supports Internet Explorer 6 or higher. However, jQuery version 2.x dropped Internet Explorer 6–8 support and supports only IE 9 and later versions.

3 How to use in bxp

The first thing that you will have to do is import the jQuery library into the area of bxp that you wish to use jQuery.

When useing jQuery in bxp you must make sure that the first line of code in your JS file is as below. Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $.We need to use other JavaScript library alongside jQuery, return control of $ back to the other library with a call to $.noConflict(). Old references of $ are saved during jQuery initialization; noConflict() simply restores them.

<script language="javascript" type="text/javascript" src="https://ww3.allnone.ie/library/javascript/jquery/jquery-1.9.1.js" ></script>

var $JQ 			= 	jQuery.noConflict();			//	This line is required to make jQuery Play nice with bxp