intro to jquery and ixedit

22
Intro to jQuery and IxEdit By Jon Marozick

Upload: ziarre

Post on 23-Feb-2016

54 views

Category:

Documents


0 download

DESCRIPTION

By Jon Marozick. Intro to jQuery and IxEdit. What is jQuery ?. JavaScript toolkit Aims to change the way developers think jQuery philosophy Find some HTML Do something to it. Why jQuery ?. Fixes cross-browser issues Powerful selectors Zebra-stripe a table - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Intro to  jQuery  and  IxEdit

Intro to jQuery and IxEdit

By Jon Marozick

Page 2: Intro to  jQuery  and  IxEdit

What is jQuery?

JavaScript toolkit Aims to change the way developers

think jQuery philosophy

Find some HTML Do something to it

Page 3: Intro to  jQuery  and  IxEdit

Why jQuery?

Fixes cross-browser issues Powerful selectors

Zebra-stripe a table▪ $(“table tr:nth-

child(even)”).addClass(“striped”); If you know CSS, you know jQuery

selectors

Page 4: Intro to  jQuery  and  IxEdit

Unobtrusive JavaScript

Separates behavior from structure CSS separates design from structure Need to wait until DOM is loaded so

elements exist window.onload = function() { … }; $(document).ready(function() { … }); or

$(function() { … });

Page 5: Intro to  jQuery  and  IxEdit

jQuery Wrapper

$(selector) or jQuery(selector) $() is a function that returns a

special JavaScript object containing an array of DOM elements that match the selector

Page 6: Intro to  jQuery  and  IxEdit

Selector Examples

$(“#post”) get element with id post $(“a.toggle”) get links with class

toggle $(“input:hidden”) get all hidden

input elements $(”input:checkbox :checked”) gets

all checkboxes that are checked $(“a[href*=jquery]”) gets all links

whose href contains the string jquery

Page 7: Intro to  jQuery  and  IxEdit

Chaining jQuery Commands $(“div

a”).fadeIn().addClass(“highlight”); Fluent Interface

Page 8: Intro to  jQuery  and  IxEdit

Effect Examples

.fadeIn() fade to opaque .fadeTo() adjusts opacity .hide() hides elements .show() displays elements .slideToggle() displays or hides

elements

Page 9: Intro to  jQuery  and  IxEdit

Manipulation Examples

.addClass() adds css class(es) .removeClass() removes css class(es) .height() get height of first element

in set .position() get coordinates of first

element in set, relative to parent

Page 10: Intro to  jQuery  and  IxEdit

Adding Content

Add banner after each div $(“div”).after(“<p>Banner

here</p>”);<html><body>

<div>Put stuff here…</div><div>Put more stuff here…</div>

</body></html>

Page 11: Intro to  jQuery  and  IxEdit

Adding Content

Add banner after each div $(“div”).after(“<p>Banner

here</p>”);<html><body>

<div>Put stuff here…</div><p>Banner here</p><div>Put more stuff here…</div><p>Banner here</p>

</body></html>

Page 12: Intro to  jQuery  and  IxEdit

AttributesGet

.attr(“checked”).html().val().css(“margin”).width()

Set.attr(“checked”,

“checked”).html(“<br />”).val(“some value”).css(“margin”, “5px”).width(150)

Page 13: Intro to  jQuery  and  IxEdit

Events

$(“button”).click(function() {// do something

}); .mouseover() .keypress() .focus() .blur() .change()

Page 14: Intro to  jQuery  and  IxEdit

Using Change Event - Html

<html><body><select name="sweets" multiple="multiple"> <option>Chocolate</option><option selected="selected">Candy</option><option>Taffy</option><option selected="selected">Caramel</option><option>Fudge</option><option>Cookie</option></select><div></div></body></html>

Page 15: Intro to  jQuery  and  IxEdit

Using Change Event - jQuery

$("select").change(function () { var str = ""; $("select

option:selected").each(function () { str += $(this).text() + " ";

}); $("div").text(str);

}).change();

Page 16: Intro to  jQuery  and  IxEdit

Using Change Event - Result

Page 17: Intro to  jQuery  and  IxEdit

Content Delivery Networks (CDN) http://code.google.com/apis/ajaxlibs/ <script

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

http://www.asp.net/ajaxlibrary/cdn.ashx

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" type="text/javascript"></script>

Page 18: Intro to  jQuery  and  IxEdit

Demo

Page 19: Intro to  jQuery  and  IxEdit

IxEdit

First on-the-fly interaction design tool

No coding Edit directly in browser Saves data in local database using

Google Gears

Page 20: Intro to  jQuery  and  IxEdit

References

www.jquery.com http://www.slideshare.net/1Marc/jque

ry-essentials jQuery In Action www.ixedit.com

Page 21: Intro to  jQuery  and  IxEdit

Contact Info

Email: [email protected] Twitter: @JonMarozick

Page 22: Intro to  jQuery  and  IxEdit

Questions