jQuery: Plugins, AJAX, AHAH David Eads Chicago T echnology - - PowerPoint PPT Presentation

jquery plugins ajax ahah
SMART_READER_LITE
LIVE PREVIEW

jQuery: Plugins, AJAX, AHAH David Eads Chicago T echnology - - PowerPoint PPT Presentation

jQuery: Plugins, AJAX, AHAH David Eads Chicago T echnology Cooperative eads@chicagotech.org http://chicagotech.org We are very fortunate. A very simple plugin (function($){ $.fn.spliceIn = function(opt) { opt = $.extend({}, { position:


slide-1
SLIDE 1

jQuery: Plugins, AJAX, AHAH

David Eads Chicago T echnology Cooperative eads@chicagotech.org http://chicagotech.org

slide-2
SLIDE 2

We are very fortunate.

slide-3
SLIDE 3

A very simple plugin

slide-4
SLIDE 4

(function($){ $.fn.spliceIn = function(opt) {

  • pt = $.extend({}, {

position: 100, text: ' <strong>Hello world!</strong> ', }, opt); return this.each(function() { body = $(this).html(); if (body.length > opt.position) { left = body.substring(0, opt.position); right = body.substring(opt.position, body.length - 1); $(this).html(left + opt.text + right); } else { $(this).append(opt.text); } }); } })(jQuery);

slide-5
SLIDE 5

AJAX: Very Easy

$('#element').load('some-file.html');

slide-6
SLIDE 6

AJAX: $.post, $.get

$.post('my-processor.php', { text: 'Some text', age: 35, author: 'Santa' }, function() { $('#alert').html('Your data was sent.'); });

slide-7
SLIDE 7

AJAX: $.getJSON

$.getJSON("http://url-of-json/", function(data){ // do something with the data } );

slide-8
SLIDE 8

AJAX: jQuery Form plugin

$('#my-form').ajaxForm(function() { $('#status').append('form submitted'); }); $('#my-form').ajaxForm({ beforeSubmit: function() { $('#status').addClass('waiting'); }, success: function() { $('#status').removeClass('waiting') .append('Successful submission.'); } });

slide-9
SLIDE 9

AHAH: Also simple

$form['topic']['set_topic'] = array( '#type' => 'submit', '#value' => t('Set Topic'), '#ahah' => array( 'path' => 'shoutbox/callback', 'wrapper' => 'shoutbox-topic', 'method' => 'replace', 'event' => 'click', 'effect' => 'fade', 'progress' => array('type' => 'throbber'), ), '#attributes' => array('class' => 'form-button'), );

slide-10
SLIDE 10

Resources

jQuery: http://jquery.com Visual jQuery: http://visualjquery.com Ajaxian: http://ajaxian.com 15 Days of jQuery: http://15daysofjquery.com “jQuery for Javascript Programmers” - Simon Willison http://simonwillison.net/2007/Aug/15/jquery/