Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation www.telerik.com.

Slides:



Advertisements
Similar presentations
Castafiore platform Consists or intend to consist of 1.Advanced Web framework 2.Advanced Graph database 3.Designer studio (something like visual basic)
Advertisements

JavaScript and AJAX Jonathan Foss University of Warwick
The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
JQuery A Javascript Library Hard things made eas(ier) Norman White.
Building a Rich Internet Application with jQuery Ben Dewey twentysix New York Fill this space.
Sep 2010 Palestinian Land Authority IT Department By Salam Turkman1 Jquery (write less do more)
Fall 2012 CSC9010 Web Technologies Web Tool Presentation Randy Escoto.
Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4.
CS428 Web Engineering Lecture 15 Introduction to Jquery.
ICS 665 Jesse Abdul. jQuery UI Overview  jQuery UI javascript library Includes all UI component functionality  jQuery UI CSS framework Includes standard.
INTRO TO MAKING A WEBSITE Mark Zhang.  HTML  CSS  Javascript  PHP  MySQL  …That’s a lot of stuff!
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Simon Amrein Consultant Trivadis AG What is ASP.NET 4.0 Ajax Ajax Control Toolkit Microsoft Ajax Content Delivery Network jQuery jQuery Client Templates.
About me I attend the Edina chapter of TechMasters Been a programmer since age 13, sparked by playing video games Currently employed at GMAC as an independent.
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
JQuery CS 268. What is jQuery? From their web site:
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
Nguyen Ich Cuong.  Course duration: 45’  Purpose: Present Introduction to JQuery  Targeted attendees: NICorp Trainee  Tests/quiz: Yes - 10’
What is jQuery?  JavaScript Library  Functionality  DOM scripting & event handling  Ajax  User interface effects  Form validation 2.
JavaScript & jQuery the missing manual Chapter 11
Yahoo! User Interface (YUI) Library Natly Mekdara.
JQuery March 09 th,2009 Create by
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
RUSS FUSTINO HEAD OF DEVELOPER JavaScript for the ASP.NET Developer Chris Bannon.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
13. jQuery See the official documentation at  See the terse API documentation at
Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn.
JavaScript Framework for Rich Apps in Every Browser Maura Wilder Joan Wortman
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Ventsislav Popov Crossroad Ltd.. 1. What is AJAX?  AJAX Concept  ASP.NET AJAX Framework 2. ASP.NET AJAX Server Controls  ScriptManager, UpdatePanel.
Animation & Effects Using JQuery. What is jQuery? jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
JQuery Youn-Hee Han
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
JQuery Overview Unleash the Power of jQuery SoftUni Team Technical Trainers Software University
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
1 What is JQuery. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax* interactions.
Unit 13 –JQuery Basics Instructor: Brent Presley.
AJAX in Ruby-on-Rails. Ruby on Rails and AJAX AJAX can be done with just Javascript Easier if you use libraries –Prototype –SAJAX –jQuery Libraries only.
SHAREPOINT & JQUERY. Hi, my name and I am a product manager at lightning tools. I have been working with SharePoint for 5 years.
Introduction to JQuery COGS 187A – Fall JQuery jQuery is a JavaScript library, and allows us to manipulate HTML and CSS after the page has been.
05 | Integrating JavaScript and MVC 4 Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
Murach's ASP.NET 4.5/C#, C2© 2013, Mike Murach & Associates, Inc.Slide 1.
SharePoint & jQuery. About me Phill Duffy – Product Manager at Lightning Tools Ltd – Author of ‘Pro SharePoint with jQuery’ – MCTS Application Developer.
What is jQuery?.
ASP.NET AJAX – Basics Svetlin Nakov Telerik Corporation
Tek Raj Chhetri Code for Humans not for machine.
Unleash the Power of jQuery
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
JQUERY Online TRAINING AT GOLOGICA
Fundamentals, DOM, Events, AJAX, UI
The Cliff Notes Version
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Tutorial 7 – Integrating Access With the Web and With Other Programs
Presentation transcript:

Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation

 jQuery Fundamentals  What is jQuery?  Selection and DOM Manipulation  Events and Chaining  Ajax  Ajax Methods  Adding Ajax to a website  jQuery Templating  Microsoft’s jQuery Contributions  Templating Syntax and render method  jQuery UI 2

The world’s most popular JavaScript library 3

 jQuery is a cross-browser JavaScript library  jQuery is a cross-browser JavaScript library  Designed to simplify the client-side scripting of HTML  jQuery is the most popular JavaScript library in use today  Free, open source software  jQuery's syntax is designed to make it easier to  Navigate a document and select DOM elements  Create animations  Handle events  Develop Ajax applications

 jQuery also provides capabilities for developers to create plugins for  Low-level interaction and animation  Advanced effects and high-level, theme-able widgets  Creation of powerful and dynamic web pages  Microsoft adopted jQuary within Visual Studio for use within Microsoft's ASP.NET AJAX Framework and ASP.NET MVC Framework 5

 Easy to learn  Fluent programming style  Easy to extend  You create new jQuery plugins by creating new JavaScript functions  Powerful DOM Selection  Powered by CSS 3.0  Lightweight  Community Support  jQuery has a large community of developers and power users

 Download it   Self hosted  You can choose to self host files  This is including jQuary in the scripts folder in Visual Studio  Download and include it in your project  CDN - Microsoft, jQuery, Google

8 Selecting, Adding, Removing Elements

 With jQuery you typically find something, then do something with it  Syntax for finding items is the same as the syntax used in CSS to apply styles.  There are lots of different jQuary methods to do with the selected elements //finding the item $("#something").hide(); //doing something with the found item

 When selecting with jQuery you can end up with more than one element  Any action taken will typically affect all the elements you have selected //...$('.myClass').hide();//...

 With jQuery HTML adding elements can be done on the fly  Very easily  Can be added to the page  Still selecting something (brand new), then doing something. $('<ul><li>Hello</li></ul>').appendTo('body'); 11

// Before <div> Red Red Green Green </div> // Removing Elements $('p').remove(); 12  You can also remove elements from the DOM  Just as easy // After <div></div>

 With jQuery binding to events is very easy  We can specify a click handler  For example by using the click method.  The above example will bind the " myClickHandler " function to all anchors with a class of tab // Binding an event function() myClickHandler { // event handling code // event handling code $(this).css(‘color’, ‘red’); $(this).css(‘color’, ‘red’);};$('a.tab').click(myClickHandler); 13

 Functions in JavaScript do not have to have a name  This is the same exact functionality as the last slide  This is important because in the previous example we polluted the global scope with a new function name  Can be dangerous as someone could overwrite your function with their own accidentally 14 $('a.tab').click( function() { // event handling code // event handling code $(this).css('color', 'red'); $(this).css('color', 'red');});

 With jQuery many methods allow chaining  Chaining is where you can continue to "chain" on methods one after another.  As an example, the addClass method will add the class ' odd ' in the code below  Then return the jQuery collection  We can immediately chain on the " click " event  Click then operates on the odd rows by adding a click handler to each of them $('tr:odd').addClass('odd').click( function () {.click( function () { alert('you clicked a tr!'); alert('you clicked a tr!'); }); }); 15

 Some jQuery methods chain and return a new collection of elements  ' Find ' and ' Filter ' are two examples.  jQuery holds on to the previous collections, essentially creating a stack set to store them. 16

 Methods like Find and Filter create a new collection which is added to stack  Older collections are pushed further 'downward' on the stack  You can get a previous collection that was placed on the stack by using the end() method. 17 $(‘body’) // [body].find(‘p’) // [p, p, p] > [body].find(‘p’) // [p, p, p] > [body].find(‘a’) // [a, a] > [p, p, p] > [body].find(‘a’) // [a, a] > [p, p, p] > [body].addClass(‘foo’).addClass(‘foo’).end() // [p, p, p] > [body].end() // [p, p, p] > [body].end() // [body].end() // [body]

 This is a popular use that shows both chaining and the stack architecture. 18 $(‘tr’).filter(‘:odd’).filter(‘:odd’).addClass(‘myOddClass’).addClass(‘myOddClass’).end().end().filter(‘:even’).filter(‘:even’).addClass(‘myEvenClass’);.addClass(‘myEvenClass’);

 We first select all rows  Then filter to only the odd rows  The odd rows are placed on the top of the stack  The 'all rows' collection is now ‘pushed downward’  Add a class to the odd rows  We call end  Throws away our odd rows collection  Grabs the next element in the stack  The 'all rows' collection  We then filter to find even rows  We add a class to the even rows 19

 Not all methods can be chained  Some methods can operate as “getters”, which return an string  Example: calling.html() with no parameters gets the HTML inside an element as a string  You can’t chain after that as you now have a string 20 var html = $(...).html().addClass('hello') // Breaking, html() returns a string. // addClass method is undefined on a string

 Calling.html() with a string as the first parameter acts as a setter - which once the HTML is set, then the jQuery collection is returned  You can then continue to chain  Visual Studio 2010 Intellisense can help when figuring out whether or not you can chain!  You can also find out whether or not a methods chains by looking at api.jquery.com api.jquery.com  A method can be chained if the method returns "jQuery" 21 $(...).html(‘Hello world’).addClass(‘hello’)

Live Demo 22

 Can use jQuery Ajax to seamlessly integrate with other jQuery code  Makes asynchronous calls to the server using http simple  jQuery.ajax()  The core method  The shortcut methods use it 'under the hood'  Thus it can do everything  $.get() and $.post()  Set a single parameter  The HTTP Action that will occur is POST or GET

 $.getJSON  Uses the get HTTP action and inform the server to send JSON back  $(...).load()  gets HTML from the server and loads it into whatever you have selected  Note that there is no selection going on (except.load() )  With certain jQuery methods there is not a logical reason to make a selection first  Most Ajax methods fall into that category

 With ASP.NET MVC, you can return a portion of a view and add it to the page with load  $(...).load()  Gets HTML from the server and load it into whatever you have selected.  You could have the ASP.NET MVC server render a partial view, and return that with load!  Note that the server should return a partial page only  If it returns a whole page, then we are going to have some invalid HTML! 26 $(‘#myContainer’).load(‘home/myHtmlSnippet’);

 With ASP.NET you can return a JSONResult, which would work in cooperation with jQuery getJSON  When JSON returns, it is treated as a JavaScript object  jQuery expects a function and we can specify the function to use inline and never have to actually name the function 27 {“names”: [“Joe”, “Jim”, “Bob”]} $.getJSON(‘my/page/route’, function(json) { function(json) { $(‘body’) $(‘body’).append( json.names[0] );.append( json.names[0] ); }); });

28

 Open, transparent and collaborative  In the spirit of jQuery community  Specification, Proposals on jQuery Forums  Prototypes as Plugins in Github  Cool Stuff = Templating, Script Loader, Data- linking 29 Microsoft: Proposal, Specification, Prototype jQuery Core Team ASP.NET Ajax Library jQuery Plugins jQuery Core

30 var template = " ${dataItem} “; <li>${dataItem}</li></script> ${Name} ${Name} Price: ${formatPrice(Price)} Price: ${formatPrice(Price)} <img data-pk="${Id}" src="Content/AddCart.png" <img data-pk="${Id}" src="Content/AddCart.png" alt="Add to Cart" class="addCart" /> alt="Add to Cart" class="addCart" /> </script>

 Making the Template and inserting a templated element  The result is 31 ${ dataItem } ${ dataItem } </script>$("#myTemplate").render(dataObject).render(dataObject).appendTo("ul");.appendTo("ul"); <ul> Beer Beer </ul>

 Making the Template and inserting an array of elements  The result is 32 ${dataItem} ${dataItem} </script>$("#myTemplate").render(arrayOfDataObjects).render(arrayOfDataObjects).appendTo("ul");.appendTo("ul"); <ul> Beer_0 Beer_0 Beer_1 Beer_1 </ul>

Live Demo 33

 jQuery UI is a separate JavaScript file  jQuery UI contains three different areas of additions  Effects  Draggable, Droppable, Resizable, Selectable, Sortable  Interactions  Show & Hide additions, Color Animation, Easings  Widgets  Accordian, Autocomplete, Button, Datepicker, Dialog, Progressbar, Slider, Tabs

 Everything is theme-able!  Adding most widgets is very simple in code: 36 $(‘input:text.date’).datepicker()

 What is jQuery?  jQuery is a cross-browser JavaScript library  jQuery is a cross-browser JavaScript library  Easier to use than JavaScript  Selection and DOM Manipulation  How to find, select and remove elements  Events and Chaining  Binding events  Chaining methods  Chain breakers

Questions?