write less do more who am i datamapper what is jquery
play

write less. do more. who am I? DataMapper what is jquery? - PowerPoint PPT Presentation

write less. do more. who am I? DataMapper what is jquery? unobtrusive h1 { color: #999; } css h1 { color: #999; } h1 { color: #999; } UJS With jQuery $(h1).click(function() { $(this).fadeIn(); }); Why do we like CSS?


  1. write less. do more.

  2. who am I?

  3. DataMapper

  4. what is jquery?

  5. unobtrusive

  6. h1 { color: #999; } css

  7. h1 { color: #999; }

  8. h1 { color: #999; } UJS With jQuery $(“h1”).click(function() { $(this).fadeIn(); });

  9. Why do we like CSS?

  10. reusable styles

  11. change-once, change-everwhere

  12. We got over <font>

  13. why should you like UJS?

  14. same reasons

  15. application-wide behavior

  16. change-once, change everywhere

  17. we’re over onclick=

  18. in short... if you like CSS, YOU’ll like UJS

  19. javascript can be fun!

  20. jquery’s core philosophy

  21. get some elements. do some stuff.

  22. some people* call it DOM-SCRIPTING. * Jeremy keith

  23. some people* call it DOM-SCRIPTING. * Jeremy keith

  24. some people* call it call it DOM-SCRIPTING. DOM-SCRIPTING. in his book: * Jeremy keith dom-scripting

  25. get some elements. but how?

  26. did i mention CSS?

  27. CSS 3 plus

  28. CSS 3 plus • div • div:first • div:header • div:last • div:animated • div#foo • div:not(#foo) • div:contains(txt) • div.class • div:even • div:empty • div, p, a • div:odd • div:has(p) • div p • div:eq(1) • div:parent • div > p • div:gt(1) • div:hidden • div + p • div:lt(1) • div:visible • div ~ p

  29. CSS 3 plus

  30. CSS 3 plus

  31. CSS 3 plus • div[foo] • :last-child • :reset • div[foo=bar] • :only-child • :button • div[foo!=bar] • :input • :file • div[foo^=bar] • :text • :hidden • div[foo$=bar] • :password • :enabled • div[foo*=bar] • :radio • :disabled • :nth-child(2) • :checkbox • :checked • :nth-child(even) • :submit • :selected • :first-child • :image

  32. CSS 3 plus

  33. get some elements.

  34. $(“table tr:nth- child(even) > td:visible”)

  35. do stuff.

  36. $(“div”) Returns jquery object

  37. $(“div”).fadeIn() Returns jquery object

  38. $(“div”).fadeIn() .css(“color”, “green”) Returns jquery object

  39. we call this chaining

  40. Crazy chains

  41. Crazy chains $(“ul.open”) // [ ul, ul, ul ] .children(“li”) // [ li, li, li ] .addClass(“open”) // [ li, li, li] .end() // [ ul, ul, ul ] . fi nd(“a”) // [ a, a, a ] .click(function(){ $(this).next().toggle(); return false; }) // [ a, a, a ] .end(); // [ ul, ul, ul ]

  42. 5 parts of jquery dom events effects ajax plugins

  43. dom

  44. dom traversal $(“div”).parent(); $(“div”).siblings(); $(“div”).next(); $(“div”).nextAll(“p”); $(“div”).nextAll(“p:first”); dom

  45. dom

  46. $(“div”) <body> <div> <div> <pre> <p> <p> <p> <p> <p> <p> dom

  47. dom

  48. $(“div#foo”).siblings() <body> <div id='foo'> <div> <pre> <p> <p> <p> <p> <p> <p> dom

  49. dom

  50. $(“div”).next() <body> <div> <div> <pre> <p> <p> <p> <p> <p> <p> dom

  51. dom

  52. $(“div”).nextall(“p”) <body> <div id='foo'> <p> <p> <pre> <p> dom

  53. dom

  54. $(“div”).nextall(“p:first”) <body> <div id='foo'> <p> <p> <pre> <p> dom

  55. dom

  56. find $(“div pre”) $(“div”).find(“pre”) dom

  57. dom

  58. $(“div pre”) <body> <div> <div> <pre> <p> <pre> <pre> <p> <pre> <p> dom

  59. dom

  60. $(“div”).find(“pre”) <body> <div> <div> <pre> <p> <pre> <pre> <p> <pre> <p> dom

  61. dom

  62. filter $(“div:contains(some text)”) $(“div”).filter(“:contains(some text)”) $(“div”).filter(function() { return $(this).text().match(“some text”) }) dom

  63. dom

  64. andself() $(“div”).siblings().andSelf() $(“div”).parent().andSelf() dom

  65. dom

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend