SlideShare a Scribd company logo
Prototype JS in Ruby On Rails Kıvanç Kantürk
Outline What is Prototype JS ? Why Prototype JS ? Speed Comparison Between Frameworks Some Problems of JS Frameworks and Prototype Some General Methods Ruby and Prototype JS
What is Prototype JS Prototype is a JavaScript framework. The reason is to ease dynamic web application development. Mainly extends DOM and JavaScript objects. Written by Sam Stephenson and friends
Why Prototype JS It is included in the Rails package.   It is better and faster in Chrome, however not for the others. Easy to implement (It depends on familiarity). Provides Ajax dynamic pages. Prototype adds better OOP support better OOP support
Speed Comparison Between Frameworks
Problems Cross browser issues Chance of name collisions Performance overheads
General Methods Main methods –  Class.create Creates a constructor that calls “initialize” You can define everything in prototype  instead of half (fields) in constructor an   half  (methods) in prototype var MyClass=  Class.create ({ initialize: function(args){functionA(){..}, functionB(){..} });
General Methods Cont’d –  Object.extend   Adds new capabilities to existing class Lets you define object hierarchies (almost  real inheritance) Object.extend called automatically if first  arg of Class.create is a class name Add properties to a single object •  var obj1 = {a: 1, b: 2}; •  var obj2 = {c: 3, d: 4}; •  Object.extend (obj1, obj2);  // obj1 has a, b, c, d
General Methods Cont’d Prototype uses  $ ( )  for id based selection. The  $()  function is a shortcut to the  most  frequent   document.getElementById()  function of the DOM. $() can   pass more than one id   and  it  will return an  Array  object with all the requested elements. var divs =  $ ('myDiv','myOtherDiv'); for(i=0; i<divs.length; i++) { alert(divs[i].innerHTML); }
General Methods Cont’d Try.these()  provides different function calls until one of them works. It takes some functions as arguments and calls them in an order. function getType(Worker){ return Try.these ( function() {return Worker.Id;}, function() {return Worker.Salary;) ); }
General Methods Cont’d Ajax.Request  class assists AJAX functionality. Assume that we have an suitable XML response. <script> function f(){ var url = ‘ http:// localhost/20000/factory’ var params = ‘workerId=’ + workerId + ‘&salary=’ + s; var MyAjax = new  Ajax.Request (url, { method: ‘get’,  parameters: params, onC omplete: displayResult} ); } function displayResult(responseData){ if (responseData){  $(‘result’).value = responseData.responseText;} else{                $('result').value = &quot;Sunucuda bir hata oluştu&quot;;} } </script>
Ruby and Prototype JS
Ruby and Prototype JS Cont’d <%= javascript_include_tag 'prototype'  %> That must be added by user in the needed .erb document
Referances http://courses.coreservlets.com/Course-Materials/pdf/ajax/Prototype-3.pdf http://sergiopereira.com/articles/DeveloperNotes-Prototype-JS.pdf http://www.slideshare.net/remy.sharp/prototype-jquery-going-from-one-to-the-other http://api.prototypejs.org/ http://www.prototypejs.org/learn/extensions http://stackoverflow.com/questions/1026080/no-route-matches-javascripts-prototype-js-explicitly-define-one http://articles.sitepoint.com/article/painless-javascript-prototype http://alternateidea.com/blog/articles/2005/12/07/prototype-meets-ruby-a-look-at-enumerable-array-and-hash http://en.wikipedia.org/wiki/Prototype_JavaScript_Framework http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks http://blog.creonfx.com/javascript/dojo-vs-jquery-vs-mootools-vs-prototype-performance-comparison

More Related Content

PPTX
Object Oriented Programming In JavaScript
PPT
Beginning Object-Oriented JavaScript
PDF
JavaScript OOPs
PPT
OOP in JavaScript
PPTX
Object Oriented JavaScript - II
PDF
JavaScript Objects
PDF
JavaScript - Chapter 8 - Objects
PDF
Performance Optimization and JavaScript Best Practices
Object Oriented Programming In JavaScript
Beginning Object-Oriented JavaScript
JavaScript OOPs
OOP in JavaScript
Object Oriented JavaScript - II
JavaScript Objects
JavaScript - Chapter 8 - Objects
Performance Optimization and JavaScript Best Practices

What's hot (20)

PPT
JavaScript In Object Oriented Way
ODP
Object Oriented Javascript
PPT
A Deeper look into Javascript Basics
PPTX
JavaScript in Object-Oriented Way
PPT
JavaScript Basics
PPTX
Functions and Objects in JavaScript
KEY
PPT
JavaScript OOP
PDF
JavaScript - Chapter 6 - Basic Functions
PDF
Advanced JavaScript - Internship Presentation - Week6
PPTX
Javascript basics for automation testing
PPT
jQuery Fundamentals
PPTX
JavaScript Literacy
PPTX
Introduction to Grails Framework
PDF
JavaScript Basics and Best Practices - CC FE & UX
PPTX
Lecture 5 javascript
PPTX
Lab #2: Introduction to Javascript
PPT
J Query
PPT
Basic Javascript
PDF
Basics of JavaScript
JavaScript In Object Oriented Way
Object Oriented Javascript
A Deeper look into Javascript Basics
JavaScript in Object-Oriented Way
JavaScript Basics
Functions and Objects in JavaScript
JavaScript OOP
JavaScript - Chapter 6 - Basic Functions
Advanced JavaScript - Internship Presentation - Week6
Javascript basics for automation testing
jQuery Fundamentals
JavaScript Literacy
Introduction to Grails Framework
JavaScript Basics and Best Practices - CC FE & UX
Lecture 5 javascript
Lab #2: Introduction to Javascript
J Query
Basic Javascript
Basics of JavaScript
Ad

Viewers also liked (11)

PPTX
Presentacion It Novation Telecom V3
PPT
Pkng02 real games 1 maniman teatro 5 slide
PDF
NPD Aftermarket Perspectives
PPT
Version Control
PPT
Kelly slide show ppt adjusted
PDF
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
PPTX
ITNNOVATION Presentation Final With Text
PDF
NPD Custom Research/Advanced Analytics
PPT
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
PPTX
How to write a formal email
Presentacion It Novation Telecom V3
Pkng02 real games 1 maniman teatro 5 slide
NPD Aftermarket Perspectives
Version Control
Kelly slide show ppt adjusted
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
ITNNOVATION Presentation Final With Text
NPD Custom Research/Advanced Analytics
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
How to write a formal email
Ad

Similar to Prototype Js (20)

PPTX
Javascript first-class citizenery
PPT
Smoothing Your Java with DSLs
PPT
PPTX
IWT presentation121232112122222225556+556.pptx
PPTX
jQuery
PDF
AJS UNIT-1 2021-converted.pdf
PPT
Prototype Utility Methods(1)
KEY
JavaScript Growing Up
ODP
Practical catalyst
PDF
IOC + Javascript
PPTX
Ruby On Rails Intro
PPT
Quebec pdo
PPTX
Java scriptforjavadev part2a
KEY
Javascript unit testing, yes we can e big
PDF
Ruby On Rails
ODP
Agile web development Groovy Grails with Netbeans
PDF
[@IndeedEng] Building Indeed Resume Search
PDF
HTML5 for the Silverlight Guy
PPT
Building Smart Workflows - Dan Diebolt
PDF
Google App Engine With Java And Groovy
Javascript first-class citizenery
Smoothing Your Java with DSLs
IWT presentation121232112122222225556+556.pptx
jQuery
AJS UNIT-1 2021-converted.pdf
Prototype Utility Methods(1)
JavaScript Growing Up
Practical catalyst
IOC + Javascript
Ruby On Rails Intro
Quebec pdo
Java scriptforjavadev part2a
Javascript unit testing, yes we can e big
Ruby On Rails
Agile web development Groovy Grails with Netbeans
[@IndeedEng] Building Indeed Resume Search
HTML5 for the Silverlight Guy
Building Smart Workflows - Dan Diebolt
Google App Engine With Java And Groovy

Prototype Js

  • 1. Prototype JS in Ruby On Rails Kıvanç Kantürk
  • 2. Outline What is Prototype JS ? Why Prototype JS ? Speed Comparison Between Frameworks Some Problems of JS Frameworks and Prototype Some General Methods Ruby and Prototype JS
  • 3. What is Prototype JS Prototype is a JavaScript framework. The reason is to ease dynamic web application development. Mainly extends DOM and JavaScript objects. Written by Sam Stephenson and friends
  • 4. Why Prototype JS It is included in the Rails package.  It is better and faster in Chrome, however not for the others. Easy to implement (It depends on familiarity). Provides Ajax dynamic pages. Prototype adds better OOP support better OOP support
  • 6. Problems Cross browser issues Chance of name collisions Performance overheads
  • 7. General Methods Main methods – Class.create Creates a constructor that calls “initialize” You can define everything in prototype instead of half (fields) in constructor an half (methods) in prototype var MyClass= Class.create ({ initialize: function(args){functionA(){..}, functionB(){..} });
  • 8. General Methods Cont’d – Object.extend Adds new capabilities to existing class Lets you define object hierarchies (almost real inheritance) Object.extend called automatically if first arg of Class.create is a class name Add properties to a single object • var obj1 = {a: 1, b: 2}; • var obj2 = {c: 3, d: 4}; • Object.extend (obj1, obj2); // obj1 has a, b, c, d
  • 9. General Methods Cont’d Prototype uses $ ( ) for id based selection. The $() function is a shortcut to the most frequent document.getElementById() function of the DOM. $() can pass more than one id and it will return an Array object with all the requested elements. var divs = $ ('myDiv','myOtherDiv'); for(i=0; i<divs.length; i++) { alert(divs[i].innerHTML); }
  • 10. General Methods Cont’d Try.these() provides different function calls until one of them works. It takes some functions as arguments and calls them in an order. function getType(Worker){ return Try.these ( function() {return Worker.Id;}, function() {return Worker.Salary;) ); }
  • 11. General Methods Cont’d Ajax.Request class assists AJAX functionality. Assume that we have an suitable XML response. <script> function f(){ var url = ‘ http:// localhost/20000/factory’ var params = ‘workerId=’ + workerId + ‘&salary=’ + s; var MyAjax = new Ajax.Request (url, { method: ‘get’, parameters: params, onC omplete: displayResult} ); } function displayResult(responseData){ if (responseData){ $(‘result’).value = responseData.responseText;} else{                $('result').value = &quot;Sunucuda bir hata oluştu&quot;;} } </script>
  • 13. Ruby and Prototype JS Cont’d <%= javascript_include_tag 'prototype'  %> That must be added by user in the needed .erb document
  • 14. Referances http://courses.coreservlets.com/Course-Materials/pdf/ajax/Prototype-3.pdf http://sergiopereira.com/articles/DeveloperNotes-Prototype-JS.pdf http://www.slideshare.net/remy.sharp/prototype-jquery-going-from-one-to-the-other http://api.prototypejs.org/ http://www.prototypejs.org/learn/extensions http://stackoverflow.com/questions/1026080/no-route-matches-javascripts-prototype-js-explicitly-define-one http://articles.sitepoint.com/article/painless-javascript-prototype http://alternateidea.com/blog/articles/2005/12/07/prototype-meets-ruby-a-look-at-enumerable-array-and-hash http://en.wikipedia.org/wiki/Prototype_JavaScript_Framework http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks http://blog.creonfx.com/javascript/dojo-vs-jquery-vs-mootools-vs-prototype-performance-comparison