Ȥ Blog

Ruby,C#

JavaScript

jQuery: liveؿǤޤ¸ߤʤǤФƥ٥Ȥꤹ

AjaxѤƤȡưŪɲä줿ƥĤ˥ܥȤ󥯤ȤäơĤ˥٥ȥϥɥꤷ礬¿Ȼפޤ
ϤޤǤϡAjaxǼƥĤڡɲäˡ٥ȥϥɥꤹ륳ɤ񤤤ƤΤǤäƷ빽ɤʤäꤷޤ
Ǥ⡢ޤʤʡȤפäƤΤǤ,jQuerylive᥽åɤѤȡñ˲ǤƤޤȤȯ
ɥȤɤȡ
	Attach a handler to the event for all elements which match the current selector, now and in the future.
ߵڤӾˤ¸ߤǤФƥ٥ȥϥɥꤹ뤳ȤǤ롢ȤΤȡ
餷ȸȤ®äƤߤ롣
ɲáפ򥯥åȡAjaxʬƥĤơڡɲäơֺפ򥯥åȤǤä롢ȤäΥڡäƤߤ롣
31

liveؿѤʤϡʴǡʬƥļˡֺץ󥯤Υ٥Ȥꤹ륳ɤ񤤤Ƥޤ
	$(function(){
		
		//ɲáץ󥯤򥯥å ñDIVǤAjaxǼƥɥȤɲä
		$("#addLink").click(function(){
			$.get("./get_partial_content", function(html){
				$(document.body).append($(html));
				
				//󥯤Υ٥
				$(".deleteLink").click(function(){
					$(this).parent().remove();
				})
]			});
		});
		
	})
Ǥ⡢νȡǤɲä뤿Ӥˡ¸κ󥯤ФƤ⥤٥ȥϥɥɲä³ƤޤޤǤǤƤޤΤǡ˸볲Ϥޤ󤬡⤷顼Ȥɽ褦Ƥˤ硢٤Ʊ顼Ȥɽ褦ʺ󥯤ǤäƤޤޤ
ǤХڡ˥٥ȴϢϤޤȤꤷƤȤǤ
ǡǽˤƤΤliveؿȤ櫓ǡɤ򼡤Τ褦˽񤭴Ƥߤ롣

	$(function(){
		
		//ɲáץ󥯤򥯥å ñDIVǤAjaxǼƥɥȤɲä
		$("#addLink").click(function(){
			$.get("./get_partial_content", function(html){
				$(document.body).append($(html));
			});
		});
		
		//嵭Υ٥ȤưŪɲä줿DIVǤΡֺץ󥯤򥯥åȡʬ(ȿDIVˤɥȤ
		$(".deleteLink").live("click", function(){
			$(this).parent().remove();
		});
	})
	
ȡưŪɲä줿ƥ class="deleteLink" ǤФƤ⥤٥ȥϥɥ餬ꤵޤ

ĶñHTMLơ֥ǥΥȥե륿ߤʤΤ¸饤֥

ŻHTMLơ֥ǥΥȥե륿Τ褦ʤΤȤȤ˾ꡢ¿ʬõФʥץȤ󤸤ʤȻפõȤäѤꤢޤ
http://www.javascripttoolbox.com/lib/table/index.php

ϡtablethǤclass°table-autofilterȤtable-filterableȤƤ, Ȥե륿󥰤ڡ󥰤ʤ⥯饤¦ǽˤñǤƤޤȤĶΤǤ

®äƤߤ롣
ޤɤơȤꤢ table.js Ȥ̾¸ƥ󥯥롼ɡJavaScript˴ؤƤϤǡʬǤʤˤɬפȤϤޤ

	<%= javascript_include_tag "table.js" %>	

ˡե륿󥰤ơ֥class° class="table-autofilter" ɲäơե륿th class="table-filterable"ꡣ
ʴǤ礦

 

<table class="table-autofilter">
  <thead>
    <th class="table-filterable">ʸ</th>	 

ơ֥إå thead, ǡԤ tbody˽񤫤ʤȥʤ褦ǤJavaScript餽ʤäƤޤ

Ŭ˥ǡäơڡɽƤߤ롣

22
35
 00
06

JavaScript̵դ򤱤

JavaScript̵դθڤ򤹤ɬפäΤǤ
㤨RubyDate饹ξ硢Τ褦2010/2/30Ȥդꤹȡȥ顼ˤʤäƤޤ

52

Ǥ⡢JavaScriptξϡ2010/3/2ȲᤵƤޤޤ
JavaScriptMonth0١ΥǥåʤΤǡ-1Ƥɬפޤ2ꤹ1ˤʤФʤޤ

15


ǡJavaScriptǤRubyDate饹Ʊ̵ͤդξϡ顼ˤƤʤʡȤȤǥեȥ᥽åɤɲäȼ˸ڤ򤹤褦ˤƤߤޤ
ĤǤˡ-1ΤľŪǤʤᡢեȥ᥽åɤǤ褦ˤޤɤͤƤ⤳äľŪǤ͡
 
 
Date.create = function(year, month, day){
    var result = new Date(year, month-1 ,day);
    if(result.getFullYear() != year || result.getMonth() != month-1 || result.getDate() != day)
        throw "invalid date";
    return result;
}

ºݤưƤߤȡ

50


Ȥ顼ˤʤޤ

 

ChromeJavaScript󥽡ʣԤScript¹

FireFoxFireBugǤϴñʣԤϤJavaScriptϡ¹ԤΤǤChormeǤ̤ˤȡʴǥ顼ˤʤäƤޤޤ
59

Alt + Enter ǤǤ͡äƤˤäܤä褦ʵɡä餦ޤޤ

28


 ˺ǿǤǤϡJavaScript󥽡 Alt + Command + j ǰȯǸƤӽФ褦ˤʤäΤϴ򤷤ǤWindowsǤǤɡޥåǤϺǿ6Ǥ褦ˤʤä褦Ǥ

ץ饰ʤHTMLơ֥ʰԽ

ñʤΤʤ顢ץ饰ʤǤ¸ǤʤΤǤäƤߤޤ
˾ȤƤϡ󥿡Ǿ岼ǤСȤȤǤΤǡʤСȤȤǡ
jQuerynext, prev᥽åɤǤ͡
ơ֥ϡǽ餫inputǤǽϤơCSSǸܤʿóɽ˸ޤ
ǡJavaScriptCSS礳äѹơȤinputǤreadonly°on/offޤ

ΤΥŽĤ褦Ȥ顢ʸСȤäƹǤʤΤǡJavaScriptʬŽĤޤ
󥿡ǤΰưʤФۤȤCSS饹ɲáǤ

42
58

 
        <script type="text/javascript" charset="utf-8">
            $(function(){
                $(".editable input").attr("readonly", "readonly").keypress(function(e){
                    if(e.keyCode == 13){

                        var className = e.target.className;

                        var next = null;
                        if(e.originalEvent.shiftKey){
                            next = $(e.target).parent().parent().prev();
                        }else{
                            next = $(e.target).parent().parent().next();
                        }

                        if(next){
                            $("input[class='" + className + "']", next).focus();
                        }
                    }
                });
                
                $("#linkEdit").click(function(){
                    $(".editable input").addClass("editable").attr("readonly", '')
                }
                
                $("#linkEdit2").click(function(){
                   $(".editable input").removeClass("editable").attr("readonly", true);
                });
            })
        </script>
ץե

Ȥ

C#ɻŻRubyФʳȯԡ
ǶDockerȤؿȤAngularJS˥ϥޤäƤ롣
¢ȤĮȤȤ˽ס

QR
QR
  • 饤֥ɥ֥