9月 2011
5件の投稿
jQuery.calcNaturalWH / jQuery.fn.calcNaturalWH
added jQuery.calcNaturalWH / jQuery.fn.calcNaturalWH() to jQuery.loadImg. This utilily function waits img loading and returns naturalWidth, naturalHeight. Also do polyfill things for non-naturalWidth/Height supported browsers. $.calcNaturalWH('img1.jpg').done(function(wh){ alert(wh.width); // 1200 alert(wh.height); //...
9月 18
How to post array to php via ajax
Simply do jQuery.fn.serialize to the form and post it to PHP. $(function(){ var $form = $('#form'); var $res = $('#res'); $form.submit(function(e){ e.preventDefault(); $.ajax({ type: 'POST', url: 'receiver.php', data: $form.serialize() }).done(function(res){ console.log(res); // got ajax result yey ...
9月 15
2 リアクション
shorten URL using bit.ly API
Using jQuery deferred is nice. https://gist.github.com/1214402 http://jsfiddle.net/gh/gist/jQuery/1.6.3/1214402/ I coded this to explain creating ajax proxy is good. Following code does perfectly same thing but is much dirty than above.  https://gist.github.com/1214521 http://jsfiddle.net/gh/gist/jQuery/1.6.3/1214521/
9月 13
Margin organization
First of all, margin organization is headache for html coders sometimes. When I code html+css, my goal is always “creating modules like LEGO.”  It is very helpful when you code a huge number of pages. In this process, margin organization is an important factor.  Need uppermargin? bottommargin? OK I know, I put top margin for this… and bottom margin for this… If you code...
9月 12
jQuery.sub() encapsulation
I’ve never used jQuery.sub() but I noticed that this is pretty useful. Here’s an example. http://jsfiddle.net/Takazudo/LHNAQ/ The instance that jQuery.sub returns is an jQuery’s subclass. This means that all prototype methods attached to this local jQuery do not consume jQuery.prototype of global jQuery. This is pretty useful when you want to make a tiny plugin for limited...
9月 6