블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

2012. 11. 23. 16:28 NodeJS/Modules

prototype.js는 AJAX(Asynchronous JavaScript and XML)에서 거의 표준 라이브러리 처럼 사용하는 라이브러리이다. 사용법을 알아보자. 하기 코드는 prototype.js를 사용했을 때 JavaScript 클래스를 만들고 객체화 하는 과정을 보여준다 


var Employee = Class.create(); // Class를 이용하여 클래스 생성 Employee.prototype = { initialize : function( name ){ // prototype.js 사용시 생성자는 initialize로 정의 this.name = name } }; var Dev = Class.create(); Dev.prototype = Object.extend( // Class 상속 extend 이용 new Employee, // 상속받을 Class 선언 { showMember : function() { var list = new Array( '홍길동', '고길동', '김길동' ); document.writeln( '<div id="표시영역">' + this.name + '★사원 명단:' + list + '</div>' ); } } ); var dev = new Dev( '개발부' );

dev.showMember();


<참조>

  - 공식 사이트 :  http://prototypejs.org (버전 1.7.1)

  - 클래스 생성, 상속, Ajax 통신, JSON(JavaScript Object Notation) 사용 튜토리얼 :  http://prototypejs.org/learn/

  - prototype.js 정의 보기 :  https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js 

  - ExtJS를 하기 전 참조지만 JavaScript 하기전 기본지식과 Aptana+Spket 개발환경 설정하기 : http://techbug.tistory.com/1

  - 애니메이션과 Drag에 좋은 라이브러리 :  http://madrobby.github.com/scriptaculous



posted by 윤영식