Upgrade to Pro — share decks privately, control downloads, hide ads and more …

jQuery y Rails - Take a walk on the wild side

jQuery y Rails - Take a walk on the wild side

Christos Zisopoulos

September 26, 2011
Tweet

Other Decks in Programming

Transcript

  1. jQuery y Rails “Take a walk on the wild side”

    Christos Zisopoulos jobandtalent.com
  2. CSS selectors #id, tag, .class, * ancestor descendant parent >

    child prev + next prev ~ siblings E[@attr] E[@attr=val] E[@attr^=val] E[@attr$=val] E[@attr*=val] E[@attr=val][@attr=val]
  3. CSS selectors #id, tag, .class, * ancestor descendant parent >

    child prev + next prev ~ siblings E[@attr] E[@attr=val] E[@attr^=val] E[@attr$=val] E[@attr*=val] E[@attr=val][@attr=val]
  4. CSS selectors :first :last :not(selector) :even :odd :eq(index) :gt(index) :lt(index)

    :contains(text) :empty :has(selector) :parent :nth-child(index) :first-child :last-child :only-child
  5. CSS selectors :first :last :not(selector) :even :odd :eq(index) :gt(index) :lt(index)

    :contains(text) :empty :has(selector) :parent :nth-child(index) :first-child :last-child :only-child
  6. CSS selectors :input :text :password :radio :checkbox :submit :image :reset

    :button :file :hidden :enabled :disabled :checked :selected :hidden :visible :header :animated
  7. CSS selectors :input :text :password :radio :checkbox :submit :image :reset

    :button :file :hidden :enabled :disabled :checked :selected :hidden :visible :header :animated
  8. Atravesar .hasClass(class) .filter(expr) .is(expr) .map(callback) .not(expr) .slice(start, end) .add(e) .children(e)

    .siblings(e) .contents() .find(e) .next(e), .nextAll(e) .prev(e), .prevAll(e) .each(callback) .size(), .length .get(), .get(index) .index(subject) .andSelf() .end()
  9. Atravesar .hasClass(class) .filter(expr) .is(expr) .map(callback) .not(expr) .slice(start, end) .add(e) .children(e)

    .siblings(e) .contents() .find(e) .next(e), .nextAll(e) .prev(e), .prevAll(e) .each(callback) .size(), .length .get(), .get(index) .index(subject) .andSelf() .end()
  10. Manipular .append(c) .appendTo(elem) .prepend(c) .prependTo(elem) .wrap(html) .wrap(elem) .wrapAll(html) .wrapAll(elem) .wrapInner(html)

    .wrapInner(elem) .after(c), .before(c) .insertAfter(c) .insertBefore(c) .replaceWith(c) .replaceAll(selector) .empty() .remove(expr) .clone(), clone(true)
  11. Manipular .append(c) .appendTo(elem) .prepend(c) .prependTo(elem) .wrap(html) .wrap(elem) .wrapAll(html) .wrapAll(elem) .wrapInner(html)

    .wrapInner(elem) .after(c), .before(c) .insertAfter(c) .insertBefore(c) .replaceWith(c) .replaceAll(selector) .empty() .remove(expr) .clone(), clone(true)
  12. Manipular .css(name) .css(name, value) .css(properties) .html() .html(value) .text() .text(value) .val()

    .val(value) .attr(name) .attr(name, value) .attr(name, function) .attr(properties) .removeAttr(name) .addClass(class) .removeClass(class) .toggleClass(class) .offset()
  13. Manipular .css(name) .css(name, value) .css(properties) .html() .html(value) .text() .text(value) .val()

    .val(value) .attr(name) .attr(name, value) .attr(name, function) .attr(properties) .removeAttr(name) .addClass(class) .removeClass(class) .toggleClass(class) .offset()
  14. Eventos .bind(type, data, fn) .one(type, data, fn) .trigger(type, data) .triggerHandler(type,

    data) .unbind(type, data) .load(fn), .resize(fn) .scroll(fn) .ready(fn) .error(), .error(fn) .mousedown(fn) .mouseup(fn) .mouseout(fn) .mousover(fn) .mousemove(fn) .keydown() .keydown(fn) .keyup() .keyup(fn) .keypress() .keypress(fn)
  15. Eventos .bind(type, data, fn) .one(type, data, fn) .trigger(type, data) .triggerHandler(type,

    data) .unbind(type, data) .load(fn), .resize(fn) .scroll(fn) .ready(fn) .error(), .error(fn) .mousedown(fn) .mouseup(fn) .mouseout(fn) .mousover(fn) .mousemove(fn) .keydown() .keydown(fn) .keyup() .keyup(fn) .keypress() .keypress(fn)
  16. Eventos .hover(fnEnter, fnLeave) .toggle(fnOn, fnOff) .blur() .blur(fn) .unblur() .unblur(fn) .click()

    .click(fn) .dblclick() .dblclick(fn) .submit() .submit(fn) .focus() .focus(fn) .select() .select(fn) .unload() .unload(fn)
  17. Eventos .hover(fnEnter, fnLeave) .toggle(fnOn, fnOff) .blur() .blur(fn) .unblur() .unblur(fn) .click()

    .click(fn) .dblclick() .dblclick(fn) .submit() .submit(fn) .focus() .focus(fn) .select() .select(fn) .unload() .unload(fn)
  18. Efectos .show() .show(speed, callback) .hide() .hide(speed, callback) .toggle() .slideUp() .slideUp(speed,

    callback) .slideDown() .slideDown(speed, callback) .fadeIn() .fadeIn(speed, callback) .fadeOut() .fadeOut(speed, callback) .fadeTo(speed, opacity, callback)
  19. Efectos .show() .show(speed, callback) .hide() .hide(speed, callback) .toggle() .slideUp() .slideUp(speed,

    callback) .slideDown() .slideDown(speed, callback) .fadeIn() .fadeIn(speed, callback) .fadeOut() .fadeOut(speed, callback) .fadeTo(speed, opacity, callback)
  20. AJAX $.ajax(options) .load(url, data, callback) .loadIfModified (url, data, callback) $.get

    (url, data, callback) $.post (url, data, callback) $.getJSON (url, data, callback) $.getScript (url, data, callback)
  21. Prototype form_remote_for form_remote_tag link_to_remote observe_field observe_form periodically_call_remote remote_form_for submit_to_remote Scriptaculous

    draggable_element drop_receiving_element sortable_element visual_effect RJS hide insert_html remove replace replace_html show toggle Funcionalidad “Drop In”
  22. $.ajaxSetup( { data: { authenticity_token : AUTH_TOKEN } }) $.post("/todo",

    {_method:"put"}); $.post("/todo", _method:"put"); Caveat Emptor (#1)
  23. Ejemplo formulario $(function() { $('form.remote').each(function() { var url = $(this).attr('action');

    $(this).find('input[@type=submit]:first').hide(); $(this).find('input[@type=text]:first') .keyup(function() { var query = $(this).val(); $('#searchResults').load( url + query + ' #results'); }); }); });
  24. Autocomplete $("#imageSearch").autocomplete("/images", { width: 320, max: 4, highlight: false, scroll:

    true, scrollHeight: 300, formatItem: function(data, i, n, value) { return "<img src='images/" + value + "'/> " + value.split(".")[0]; }, formatResult: function(data, value) { return value.split(".")[0]; } });
  25. jQuery UI Interaction Draggable Droppable Resizable Selectable Sortable Widgets Accordion

    Autocomplete Colorpicker Dialog Slider Tabs Datepicker Magnifier Progressbar Spinner Effects "Blind" "Bounce" "Clip" "Drop" "Explode" "Fold" "Highlight" "Pulsate" "Scale" "Shake" "Slide" "Transfer"