SlideShare a Scribd company logo
1 of 38
Download to read offline
AMIR BARYLKO

AWESOME HTML5
      WITH
 UJS, JQUERY &
 COFFEESCRIPT
ABOUT ME
•   Architect
•   Developer
•   Mentor
•   Great cook
•   Software Quality Expert at mavenTHOUGHT Inc.
CONTACT INFO
•   Email: amir@barylko.com

•   Twitter: @abarylko

•   Slides: http://orthocoders.com/presentations.html

•   Company: http://maventhought.com
HTML5
SEMANTIC HTML

•   Communication is key
•   Being expressive
•   Show intent
•   Cleaner
STRUCTURE WITH
   MEANING
•   Section   •   Nav
•   Header    •   Article
•   Footer
•   Aside
ARE YOU SURE?

•   Which comes first, the section or the article?
•   I have a section with multiple articles...
•   Or is it an article with multiple sections?
•   What should I do?
IS IT COMPATIBLE?

•   Well.... (not for IE)
•   Modernizr will fix it for you!
•   And generate the code to let those tags behave as
    blocks, etc....
DATA ATTRIBUTES

•   Add custom values to tags
•   The attribute has to start with data-*
•   The value could be any string, for example:
    <span data-id='309'
          data-title='someTitle' data-time='10:00:30'> ...
USAGES

•   Store information related to your model or view
    model
•   Common usages like confirmation with data-
    confirm
JQUERY
WHAT IS IT?
•   Javascript library/framework to provide easy access
•   to operations that manipulate the DOM
•   to interact with the contents of the page
•   to a repository of plugins for common functionality
•   much more....
QUERYING WITH
     CSS SELECTOR
•   Elements in the page can be selected using css
    selection syntax
    •   $('#movies')

    •   $('#movies a.movie')

    •   $('#movies > li')
MANIPULATE
          DOM
•   Modify the element classes
    •   $('.movie').addClass('new-release')

    •   $('.movie').toggleClass('selected')

•   Add elements or remove elements
    •   $('.movie').append(....)
EVENTS

•   Bind functions/handlers to events
      •   $(document).ready(function() { ... });

      •   $('#movies').on('click', function(e) { .... })
UNOBSTRUSIVE
 JAVASCRIPT
WIKIPEDIA SAYS
Unobtrusive JavaScript is a general approach to the use of
JavaScript in web pages. Though the term is not formally defined, its basic
principles are generally understood to include:

■ Separation of functionality (the "behavior layer") from a Web page's
  structure/content and presentation[1]
■ Best practices to avoid the problems of traditional JavaScript
  programming (such as browser inconsistencies and lack ofscalability)
■ Progressive enhancement to support user agents that may not support
  advanced JavaScript functionality
VS CONFIG
<appSettings>

  <add key="webpages:Version" value="1.0.0.0" />

  <add key="ClientValidationEnabled" value="true" />

  <add key="UnobtrusiveJavaScriptEnabled" value="true"/>

</appSettings>
CLIENT SIDE
     VALIDATION
@Html.Script("jquery.validate.min.js")

@Html.Script("jquery.validate.unobtrusive.min.js")
MODEL
       ATTRIBUTES
•   System.ComponentModel.DataAnnotations
•   Helpers will generate extra code
•   jQuery adds the functionality out of the box!
GIVEN THE
      MODEL
public interface IMovie
{
    [Required]
    string Title { get; }

    DateTime ReleaseDate { get; set; }
}
ACTUAL HTML
<label for="Title">Title</label>

<input id="Title"
       class="text-box single-line input-validation-error"
       type="text" value=""
       name="Title"
       data-val-required="The Title field is required."
       data-val="true">
...
WHY
     UNOBTRUSIVE?
•   Stay out of the way!
•   Separate behavior from markup
•   Use a different file for the Javascript code
•   Use jQuery to handle events, etc...
NO MORE
HANDLERS INLINE
•   Instead of
    <a class="btn" href="#" onclick="addMovie()">

•   Use jQuery to bind the event
    <a class="btn" href="#" id="add-movie">
    $('#add-movie').on('click', addMovie);
COFFEESCRIPT
ANOTHER
    ENERGY DRINK?
•   From coffeescript.org:
    •   CoffeeScript is a little language that compiles into
        JavaScript. Underneath all those awkward braces and
        semicolons, JavaScript has always had a gorgeous object
        model at its heart. CoffeeScript is an attempt to expose
        the good parts of JavaScript in a simple way.


•   The website has a great tutorial showing side by
    side comparison with Javascript
STRING
    INTERPOLATION
•   You can concatenate inside a double quote string
    using the “#” and “{ }”
    •   "The result is #{3}" == "The result is 3"

•   Or use any expression
    •   "/movies/#{id}"
FUNCTIONS

•   The arrow/lambda is used to define functions
    •   square = (x) -> x * x

•   Parenthesis are optional when passing parameters
    •   storageDelete movieId, true
FUNCTIONS II

•   Return implicit (the last expression is the return
    value)

•Multiple lines, indentation is important
    deleteMovie = (e) ->
      movieId = $(e.target)....
      storageDelete(movieId)
OBJECTS

•   Objects are declared using indentation
    config =
      local:
        user:   'dev'
        pwd:    'dev123'
      remote:
        user:   'superdev'
        pwd:    "impossibleToGuess"
MAPS & ARRAYS

•   Arrays are declared with “[ ]”
    •   deploy = ['local', 'remote', 'uat']

•   And maps using “{ }”
    •   testing = {v1: true, v2: false, v3: true}
CONDITIONALS

•   Classic if does not need parenthesis or brackets
    if isJson
      callIndex()
      display()
    else
      dont()

•   Or use unless for the negated form
CONDITIONALS
      POSTFIX
•   The conditionals can be use as modifiers
    •   callIndex() if isJson

    •   exit() unless validated and inContext
LIST
COMPREHENSION
•   Iterate and call a function over each element
    •   deploy env for env in ['local', 'uat', 'prod']

•   Or filter over a collection
    •   allSelected = (n for n in nodes when n.selected)
CLASSES
class MovieRepository

  newMovie: ->
    $.ajax
      url: someUrl
      success: (data) -> $(id).append data
TESTING

•   Is just Javascript
•   so use Jasmine
•   or Qunit
•   any other....
DEBUGGING

•   Same variable names
•   Just set a breakpoint in the code
•   and add watches, etc....
CONTACT INFO
•   Email: amir@barylko.com

•   Twitter: @abarylko

•   Slides: http://orthocoders.com/presentations.html

•   Company: http://maventhought.com

More Related Content

What's hot

Jina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web InterfacesJina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web InterfacesDevConFu
 
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Jesse Velez
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introductionAllen Wu
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationJeremy Ward
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecJoseph Wilk
 
Choosing your animation adventure - Generate NYC 2018
Choosing your animation adventure  - Generate NYC 2018Choosing your animation adventure  - Generate NYC 2018
Choosing your animation adventure - Generate NYC 2018Val Head
 
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridPG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridAlex Blom
 
Arva JS Developer Introduction
Arva JS Developer IntroductionArva JS Developer Introduction
Arva JS Developer IntroductionTom Clement
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 WebJoseph Wilk
 

What's hot (12)

Jina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web InterfacesJina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web Interfaces
 
Fastest css3 animations
Fastest css3 animations Fastest css3 animations
Fastest css3 animations
 
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introduction
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
 
Testing Alexa Skill
Testing Alexa SkillTesting Alexa Skill
Testing Alexa Skill
 
Choosing your animation adventure - Generate NYC 2018
Choosing your animation adventure  - Generate NYC 2018Choosing your animation adventure  - Generate NYC 2018
Choosing your animation adventure - Generate NYC 2018
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJS
 
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridPG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & Hybrid
 
Arva JS Developer Introduction
Arva JS Developer IntroductionArva JS Developer Introduction
Arva JS Developer Introduction
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 

Similar to Awesome html with ujs, jQuery and coffeescript

Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationSean Burgess
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
JavaScript!
JavaScript!JavaScript!
JavaScript!RTigger
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsFabian Jakobs
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQueryGill Cleeren
 
Galen Framework - Responsive Design Automation
Galen Framework - Responsive Design AutomationGalen Framework - Responsive Design Automation
Galen Framework - Responsive Design AutomationVenkat Ramana Reddy Parine
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
Untangling the web10
Untangling the web10Untangling the web10
Untangling the web10Derek Jacoby
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsFabio Franzini
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletonGeorge Nguyen
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!Ortus Solutions, Corp
 
Quick start with AngularJS
Quick start with AngularJSQuick start with AngularJS
Quick start with AngularJSIuliia Baranova
 
Angular from a Different Angle
Angular from a Different AngleAngular from a Different Angle
Angular from a Different AngleJeremy Likness
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 

Similar to Awesome html with ujs, jQuery and coffeescript (20)

Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
Galen Framework - Responsive Design Automation
Galen Framework - Responsive Design AutomationGalen Framework - Responsive Design Automation
Galen Framework - Responsive Design Automation
 
Galenframework
GalenframeworkGalenframework
Galenframework
 
Galenframework
GalenframeworkGalenframework
Galenframework
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
 
Untangling the web10
Untangling the web10Untangling the web10
Untangling the web10
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Quick start with AngularJS
Quick start with AngularJSQuick start with AngularJS
Quick start with AngularJS
 
Angular from a Different Angle
Angular from a Different AngleAngular from a Different Angle
Angular from a Different Angle
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 

More from Amir Barylko

Functional converter project
Functional converter projectFunctional converter project
Functional converter projectAmir Barylko
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web developmentAmir Barylko
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep diveAmir Barylko
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting trainingAmir Barylko
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessAmir Barylko
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6Amir Barylko
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideAmir Barylko
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityAmir Barylko
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilitiesAmir Barylko
 
Rich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptRich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 

More from Amir Barylko (20)

Functional converter project
Functional converter projectFunctional converter project
Functional converter project
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
No estimates
No estimatesNo estimates
No estimates
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep dive
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting training
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomeness
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6
 
Productive teams
Productive teamsProductive teams
Productive teams
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other side
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivity
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilities
 
Refactoring
RefactoringRefactoring
Refactoring
 
Sass & bootstrap
Sass & bootstrapSass & bootstrap
Sass & bootstrap
 
Rich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptRich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; Coffeescript
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

Awesome html with ujs, jQuery and coffeescript

  • 1. AMIR BARYLKO AWESOME HTML5 WITH UJS, JQUERY & COFFEESCRIPT
  • 2. ABOUT ME • Architect • Developer • Mentor • Great cook • Software Quality Expert at mavenTHOUGHT Inc.
  • 3. CONTACT INFO • Email: amir@barylko.com • Twitter: @abarylko • Slides: http://orthocoders.com/presentations.html • Company: http://maventhought.com
  • 5. SEMANTIC HTML • Communication is key • Being expressive • Show intent • Cleaner
  • 6. STRUCTURE WITH MEANING • Section • Nav • Header • Article • Footer • Aside
  • 7. ARE YOU SURE? • Which comes first, the section or the article? • I have a section with multiple articles... • Or is it an article with multiple sections? • What should I do?
  • 8. IS IT COMPATIBLE? • Well.... (not for IE) • Modernizr will fix it for you! • And generate the code to let those tags behave as blocks, etc....
  • 9. DATA ATTRIBUTES • Add custom values to tags • The attribute has to start with data-* • The value could be any string, for example: <span data-id='309' data-title='someTitle' data-time='10:00:30'> ...
  • 10. USAGES • Store information related to your model or view model • Common usages like confirmation with data- confirm
  • 12. WHAT IS IT? • Javascript library/framework to provide easy access • to operations that manipulate the DOM • to interact with the contents of the page • to a repository of plugins for common functionality • much more....
  • 13. QUERYING WITH CSS SELECTOR • Elements in the page can be selected using css selection syntax • $('#movies') • $('#movies a.movie') • $('#movies > li')
  • 14. MANIPULATE DOM • Modify the element classes • $('.movie').addClass('new-release') • $('.movie').toggleClass('selected') • Add elements or remove elements • $('.movie').append(....)
  • 15. EVENTS • Bind functions/handlers to events • $(document).ready(function() { ... }); • $('#movies').on('click', function(e) { .... })
  • 17. WIKIPEDIA SAYS Unobtrusive JavaScript is a general approach to the use of JavaScript in web pages. Though the term is not formally defined, its basic principles are generally understood to include: ■ Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation[1] ■ Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack ofscalability) ■ Progressive enhancement to support user agents that may not support advanced JavaScript functionality
  • 18. VS CONFIG <appSettings> <add key="webpages:Version" value="1.0.0.0" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> </appSettings>
  • 19. CLIENT SIDE VALIDATION @Html.Script("jquery.validate.min.js") @Html.Script("jquery.validate.unobtrusive.min.js")
  • 20. MODEL ATTRIBUTES • System.ComponentModel.DataAnnotations • Helpers will generate extra code • jQuery adds the functionality out of the box!
  • 21. GIVEN THE MODEL public interface IMovie { [Required] string Title { get; } DateTime ReleaseDate { get; set; } }
  • 22. ACTUAL HTML <label for="Title">Title</label> <input id="Title" class="text-box single-line input-validation-error" type="text" value="" name="Title" data-val-required="The Title field is required." data-val="true"> ...
  • 23. WHY UNOBTRUSIVE? • Stay out of the way! • Separate behavior from markup • Use a different file for the Javascript code • Use jQuery to handle events, etc...
  • 24. NO MORE HANDLERS INLINE • Instead of <a class="btn" href="#" onclick="addMovie()"> • Use jQuery to bind the event <a class="btn" href="#" id="add-movie"> $('#add-movie').on('click', addMovie);
  • 26. ANOTHER ENERGY DRINK? • From coffeescript.org: • CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way. • The website has a great tutorial showing side by side comparison with Javascript
  • 27. STRING INTERPOLATION • You can concatenate inside a double quote string using the “#” and “{ }” • "The result is #{3}" == "The result is 3" • Or use any expression • "/movies/#{id}"
  • 28. FUNCTIONS • The arrow/lambda is used to define functions • square = (x) -> x * x • Parenthesis are optional when passing parameters • storageDelete movieId, true
  • 29. FUNCTIONS II • Return implicit (the last expression is the return value) •Multiple lines, indentation is important deleteMovie = (e) -> movieId = $(e.target).... storageDelete(movieId)
  • 30. OBJECTS • Objects are declared using indentation config = local: user: 'dev' pwd: 'dev123' remote: user: 'superdev' pwd: "impossibleToGuess"
  • 31. MAPS & ARRAYS • Arrays are declared with “[ ]” • deploy = ['local', 'remote', 'uat'] • And maps using “{ }” • testing = {v1: true, v2: false, v3: true}
  • 32. CONDITIONALS • Classic if does not need parenthesis or brackets if isJson callIndex() display() else dont() • Or use unless for the negated form
  • 33. CONDITIONALS POSTFIX • The conditionals can be use as modifiers • callIndex() if isJson • exit() unless validated and inContext
  • 34. LIST COMPREHENSION • Iterate and call a function over each element • deploy env for env in ['local', 'uat', 'prod'] • Or filter over a collection • allSelected = (n for n in nodes when n.selected)
  • 35. CLASSES class MovieRepository newMovie: -> $.ajax url: someUrl success: (data) -> $(id).append data
  • 36. TESTING • Is just Javascript • so use Jasmine • or Qunit • any other....
  • 37. DEBUGGING • Same variable names • Just set a breakpoint in the code • and add watches, etc....
  • 38. CONTACT INFO • Email: amir@barylko.com • Twitter: @abarylko • Slides: http://orthocoders.com/presentations.html • Company: http://maventhought.com