prototype.jsからjQueryに移行するたったひとつの冴えたやりかた


os0x
(Twitter)3*1
prototype.js使jQuery

そもそも、なんでjQueryに移行するのか


prototype.jsjQuery使jQueryjQuery使使jQuery使
JavaScript()
jQuery
prototype.jsjQuery

prototype.js依存をなくす


jQueryprototype.js
prototype.jsjQueryAjax
new Ajax.Request(url, {
  onSuccess: function(response) {
    // 
  }
});
jQuery.ajax({url:url, success:function(response){
  // 
});
new Ajax.Updater('id', url, {
  parameters: params
});
jQuery.ajax({
 url:url,
 data:params,
 success:function(response){
  jQuery('#id').html(response);
});




Element  jQuery().show/hide...

Event  jQuery().bind

$('id')  jQuery('#id')

$$('#id .class')  jQuery('#id .class')

$A(arguments).each(function(){})  jQuery.each(arguments,function(){})

$H({}).each(function(){})  jQuery.each({},function(){})


$EventAjax
jQuery$使jQuery

jQueryで正しく動いているかの検証


jQuery
window.onerrorFirefoxIEwindow.onerrorJavaScriptFirefox(new Error)IE*2

まとめ




jQuery
[PR] 

*1:この展開、最近どこかで見ましたか?きっと気のせいです。

*2:ちなみにちょうど今日、WebKitもエラーを捕まえられるようになりました[http://trac.webkit.org/changeset/76216:title]