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
Ad

More Related Content

What's hot (20)

JavaScript In Object Oriented Way
JavaScript In Object Oriented WayJavaScript In Object Oriented Way
JavaScript In Object Oriented Way
Borey Lim
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
NexThoughts Technologies
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
Mindfire Solutions
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Mats Bryntse
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
Dhananjay Kumar
 
Week3
Week3Week3
Week3
Will Gaybrick
 
JavaScript OOP
JavaScript OOPJavaScript OOP
JavaScript OOP
Doncho Minkov
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
Vikas Thange
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
Doncho Minkov
 
JavaScript Literacy
JavaScript LiteracyJavaScript Literacy
JavaScript Literacy
David Jacobs
 
Introduction to Grails Framework
Introduction to Grails FrameworkIntroduction to Grails Framework
Introduction to Grails Framework
PT.JUG
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
JWORKS powered by Ordina
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
Mujtaba Haider
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
J Query
J QueryJ Query
J Query
ravinxg
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
Bunlong Van
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
JavaScript In Object Oriented Way
JavaScript In Object Oriented WayJavaScript In Object Oriented Way
JavaScript In Object Oriented Way
Borey Lim
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
Mindfire Solutions
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
Dhananjay Kumar
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
Vikas Thange
 
JavaScript Literacy
JavaScript LiteracyJavaScript Literacy
JavaScript Literacy
David Jacobs
 
Introduction to Grails Framework
Introduction to Grails FrameworkIntroduction to Grails Framework
Introduction to Grails Framework
PT.JUG
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
JWORKS powered by Ordina
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
Bunlong Van
 

Viewers also liked (11)

Presentacion It Novation Telecom V3
Presentacion It Novation Telecom V3Presentacion It Novation Telecom V3
Presentacion It Novation Telecom V3
itnnovation
 
NPD Aftermarket Perspectives
NPD Aftermarket PerspectivesNPD Aftermarket Perspectives
NPD Aftermarket Perspectives
buddhand
 
Version Control
Version ControlVersion Control
Version Control
Kivanc Kanturk
 
Kelly slide show ppt adjusted
Kelly slide show   ppt adjustedKelly slide show   ppt adjusted
Kelly slide show ppt adjusted
jkellyverizonnet
 
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรมแชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
Ittichai Janthawong
 
ITNNOVATION Presentation Final With Text
ITNNOVATION Presentation Final   With TextITNNOVATION Presentation Final   With Text
ITNNOVATION Presentation Final With Text
itnnovation
 
NPD Custom Research/Advanced Analytics
NPD Custom Research/Advanced AnalyticsNPD Custom Research/Advanced Analytics
NPD Custom Research/Advanced Analytics
buddhand
 
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk
 
How to write a formal email
How to write a formal emailHow to write a formal email
How to write a formal email
efanreeche
 
Hb
HbHb
Hb
Oscar Gomez Jr
 
Presentacion It Novation Telecom V3
Presentacion It Novation Telecom V3Presentacion It Novation Telecom V3
Presentacion It Novation Telecom V3
itnnovation
 
NPD Aftermarket Perspectives
NPD Aftermarket PerspectivesNPD Aftermarket Perspectives
NPD Aftermarket Perspectives
buddhand
 
Kelly slide show ppt adjusted
Kelly slide show   ppt adjustedKelly slide show   ppt adjusted
Kelly slide show ppt adjusted
jkellyverizonnet
 
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรมแชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
แชร์เทคนิคสอนลูก เก่งเลข ด้วย 4 กิจกรรม
Ittichai Janthawong
 
ITNNOVATION Presentation Final With Text
ITNNOVATION Presentation Final   With TextITNNOVATION Presentation Final   With Text
ITNNOVATION Presentation Final With Text
itnnovation
 
NPD Custom Research/Advanced Analytics
NPD Custom Research/Advanced AnalyticsNPD Custom Research/Advanced Analytics
NPD Custom Research/Advanced Analytics
buddhand
 
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk Swe550 Fall2010 Capability Maturity Model Integration (Cmmi)
Kivanc Kanturk
 
How to write a formal email
How to write a formal emailHow to write a formal email
How to write a formal email
efanreeche
 
Ad

Similar to Prototype Js (20)

Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
Manish Kumar Singh
 
IWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptxIWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
jQuery
jQueryjQuery
jQuery
Vishwa Mohan
 
AJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdfAJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdf
SreeVani74
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
mussawir20
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
Brian Cavalier
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
Sarah Allen
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
Valentine Dianov
 
Java scriptforjavadev part2a
Java scriptforjavadev part2aJava scriptforjavadev part2a
Java scriptforjavadev part2a
Makarand Bhatambarekar
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
Balint Erdi
 
Agile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with NetbeansAgile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with Netbeans
Carol McDonald
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search
indeedeng
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan Diebolt
QuickBase, Inc.
 
Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
Ken Kousen
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
IWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptxIWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
AJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdfAJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdf
SreeVani74
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
mussawir20
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
Sarah Allen
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 
Agile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with NetbeansAgile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with Netbeans
Carol McDonald
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search
indeedeng
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan Diebolt
QuickBase, Inc.
 
Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
Ken Kousen
 
Ad

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