SlideShare uma empresa Scribd logo
1 de 19
symfony & jQuery ties and separations Massimiliano Arione April, 26th 2011
About me ,[object Object],[object Object],[object Object],[object Object]
symfony
jQuery
MVC
CPB
[object Object],[object Object],[object Object],[object Object]
PROGRESSIVE ENHANCEMENT: THE WRONG WAY ,[object Object],[object Object],[object Object],[object Object]
PROGRESSIVE   ENHACEMENT: THE GOOD WAY Just use plain javascript!
AJAX: THE 4 STEPS ,[object Object],[object Object],[object Object],[object Object]
AJAX: THE WRONG WAY 1.0 Javascript helper  1.4 sfJqueryPlugin
AJAX: THE GOOD WAY ,[object Object],[object Object],[object Object],[object Object]
IN PRACTICE: LINK <?php echo   link_to (' + ', ' cart_increase ', $item) $(' div#cart a.increase ').click(ajaxIncrease);
var  ajaxIncrease =  function (e) {   $.ajax({     url:     this.href + ' ?sf_format=json ',     success:  function (r) { increase(r, e.target); }   });    return false ; }; var  increase =  function (result, a) {    var  $li = $(a).parents('li');    var  $span = $li.find('span.quantity');    var  oldq = parseInt($span.text(),  10 );    var  newq = oldq +  1 ;   $span.empty().append(newq);   $(' span#total ').empty();   $(' span#total ').append(result.total); };
<?php // cartIncreaseSuccess.json.php use_helper(' Number ');   $arr = array(   ' total ' => format_currency($sf_user->getCartTotal(), ' EUR '), ); echo  json_encode($arr);
<?php // actions.class.php public  function  executeCartIncrease(sfWebRequest $request) {   $this->product = $this->getRoute()->getProduct();   $this->getUser()->cartIncrease($this->product);   // was $this->redirect('@homepage');       $this->redirectUnless($request->isXmlHttpRequest(), ' @homepage '); }
IN PRACTICE: FORM $(' div#filters form ').submit(ajaxFilter);
var  ajaxFilter = function(e) {    var  $form = $(this);   $.ajax({     type:    ' POST ',     url:     $form.attr('action') + ' ?sf_format=json ',     data:    $form.serializeArray(),     success: showProducts   });    return false ; };
Thanks! Massimiliano Arione @ garakkio blog.garak.it github.com/garak/sfjqec

Mais conteúdo relacionado

Mais procurados

Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)
Adam Štipák
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivars
Leonardo Soto
 
Prefixルーティングとthemeのススメ
PrefixルーティングとthemeのススメPrefixルーティングとthemeのススメ
Prefixルーティングとthemeのススメ
Shusuke Otomo
 

Mais procurados (20)

Oop php 5
Oop php 5Oop php 5
Oop php 5
 
Ch2(working with forms)
Ch2(working with forms)Ch2(working with forms)
Ch2(working with forms)
 
BDD revolution - or how we came back from hell
BDD revolution - or how we came back from hellBDD revolution - or how we came back from hell
BDD revolution - or how we came back from hell
 
Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
 
8.1
8.18.1
8.1
 
Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)Nette framework (WebElement #27 lightning talk)
Nette framework (WebElement #27 lightning talk)
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHP
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
Table through php
Table through phpTable through php
Table through php
 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivars
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
 
week-2x
week-2xweek-2x
week-2x
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravel
 
CSS3 vs jQuery
CSS3 vs jQueryCSS3 vs jQuery
CSS3 vs jQuery
 
[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)
 
Dig1108 Lesson 3
Dig1108 Lesson 3Dig1108 Lesson 3
Dig1108 Lesson 3
 
Paycheck Calculator Code - Intro to Programming Logic
Paycheck Calculator Code - Intro to Programming LogicPaycheck Calculator Code - Intro to Programming Logic
Paycheck Calculator Code - Intro to Programming Logic
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandler
 
Fat Arrow (ES6)
Fat Arrow (ES6)Fat Arrow (ES6)
Fat Arrow (ES6)
 
Prefixルーティングとthemeのススメ
PrefixルーティングとthemeのススメPrefixルーティングとthemeのススメ
Prefixルーティングとthemeのススメ
 

Destaque

Gestione delle dipendenze con Composer
Gestione delle dipendenze con ComposerGestione delle dipendenze con Composer
Gestione delle dipendenze con Composer
Massimiliano Arione
 

Destaque (6)

Gestione delle dipendenze con Composer
Gestione delle dipendenze con ComposerGestione delle dipendenze con Composer
Gestione delle dipendenze con Composer
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Case study OmniAuto.it
Case study OmniAuto.itCase study OmniAuto.it
Case study OmniAuto.it
 
Lessons learned in PHP
Lessons learned in PHPLessons learned in PHP
Lessons learned in PHP
 
Sviluppo rapido di applicazioni con PHP
Sviluppo rapido di applicazioni con PHPSviluppo rapido di applicazioni con PHP
Sviluppo rapido di applicazioni con PHP
 
PHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggioPHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggio
 

Semelhante a symfony & jQuery (PUG)

Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
Andrew Curioso
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Roel Hartman
 

Semelhante a symfony & jQuery (PUG) (20)

Smarter Interfaces with jQuery (and Drupal)
Smarter Interfaces with jQuery (and Drupal)Smarter Interfaces with jQuery (and Drupal)
Smarter Interfaces with jQuery (and Drupal)
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
TPSE Thailand 2015 - Rethinking Web with React and Flux
TPSE Thailand 2015 - Rethinking Web with React and FluxTPSE Thailand 2015 - Rethinking Web with React and Flux
TPSE Thailand 2015 - Rethinking Web with React and Flux
 
Scti 2011 minicurso jquery
Scti 2011 minicurso jqueryScti 2011 minicurso jquery
Scti 2011 minicurso jquery
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
jQuery Performance Rules
jQuery Performance RulesjQuery Performance Rules
jQuery Performance Rules
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
PHP and COM
PHP and COMPHP and COM
PHP and COM
 
You Know WebOS
You Know WebOSYou Know WebOS
You Know WebOS
 
J Query Presentation
J Query PresentationJ Query Presentation
J Query Presentation
 
Web Application Introduction
Web Application  IntroductionWeb Application  Introduction
Web Application Introduction
 
Web Application Introduction
Web Application  IntroductionWeb Application  Introduction
Web Application Introduction
 
Web Application Introduction
Web Application  IntroductionWeb Application  Introduction
Web Application Introduction
 

Mais de Massimiliano Arione

Mais de Massimiliano Arione (17)

Typed models pug roma febbraio 2020
Typed models   pug roma febbraio 2020Typed models   pug roma febbraio 2020
Typed models pug roma febbraio 2020
 
Pipelines!
Pipelines! Pipelines!
Pipelines!
 
Il nostro amico Stan
Il nostro amico Stan   Il nostro amico Stan
Il nostro amico Stan
 
PSR7 - interoperabilità HTTP
PSR7 - interoperabilità HTTPPSR7 - interoperabilità HTTP
PSR7 - interoperabilità HTTP
 
Disinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere feliciDisinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere felici
 
MAGA - PUG Roma giugno 2017
MAGA - PUG Roma giugno 2017MAGA - PUG Roma giugno 2017
MAGA - PUG Roma giugno 2017
 
PHP7 e Rich Domain Model
PHP7 e Rich Domain ModelPHP7 e Rich Domain Model
PHP7 e Rich Domain Model
 
PHP on the desktop
PHP on the desktopPHP on the desktop
PHP on the desktop
 
Scrivere e leggere log con elastic
Scrivere e leggere log con elasticScrivere e leggere log con elastic
Scrivere e leggere log con elastic
 
The metrics
The metricsThe metrics
The metrics
 
Managing frontend libs in your Symfony project
Managing frontend libs in your Symfony projectManaging frontend libs in your Symfony project
Managing frontend libs in your Symfony project
 
Translating symfony docs
Translating symfony docsTranslating symfony docs
Translating symfony docs
 
Managing frontend libs in your php project
Managing frontend libs in your php projectManaging frontend libs in your php project
Managing frontend libs in your php project
 
Gestire librerie di frontend in php
Gestire librerie di frontend in phpGestire librerie di frontend in php
Gestire librerie di frontend in php
 
Symfony: un framework per il web
Symfony: un framework per il webSymfony: un framework per il web
Symfony: un framework per il web
 
Symfony ignite
Symfony igniteSymfony ignite
Symfony ignite
 
Phpcon2009 Php e Sicurezza
Phpcon2009 Php e SicurezzaPhpcon2009 Php e Sicurezza
Phpcon2009 Php e Sicurezza
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
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
Victor Rentea
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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
 
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...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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...
 

symfony & jQuery (PUG)

  • 1. symfony & jQuery ties and separations Massimiliano Arione April, 26th 2011
  • 2.
  • 5. MVC
  • 6. CPB
  • 7.
  • 8.
  • 9. PROGRESSIVE   ENHACEMENT: THE GOOD WAY Just use plain javascript!
  • 10.
  • 11. AJAX: THE WRONG WAY 1.0 Javascript helper 1.4 sfJqueryPlugin
  • 12.
  • 13. IN PRACTICE: LINK <?php echo link_to (' + ', ' cart_increase ', $item) $(' div#cart a.increase ').click(ajaxIncrease);
  • 14. var ajaxIncrease = function (e) {   $.ajax({     url:     this.href + ' ?sf_format=json ',     success: function (r) { increase(r, e.target); }   });   return false ; }; var increase = function (result, a) {   var $li = $(a).parents('li');   var $span = $li.find('span.quantity');   var oldq = parseInt($span.text(), 10 );   var newq = oldq + 1 ;   $span.empty().append(newq);   $(' span#total ').empty();   $(' span#total ').append(result.total); };
  • 15. <?php // cartIncreaseSuccess.json.php use_helper(' Number ');   $arr = array(   ' total ' => format_currency($sf_user->getCartTotal(), ' EUR '), ); echo json_encode($arr);
  • 16. <?php // actions.class.php public function executeCartIncrease(sfWebRequest $request) {   $this->product = $this->getRoute()->getProduct();   $this->getUser()->cartIncrease($this->product);   // was $this->redirect('@homepage');     $this->redirectUnless($request->isXmlHttpRequest(), ' @homepage '); }
  • 17. IN PRACTICE: FORM $(' div#filters form ').submit(ajaxFilter);
  • 18. var ajaxFilter = function(e) {   var $form = $(this);   $.ajax({     type:    ' POST ',     url:     $form.attr('action') + ' ?sf_format=json ',     data:    $form.serializeArray(),     success: showProducts   });   return false ; };
  • 19. Thanks! Massimiliano Arione @ garakkio blog.garak.it github.com/garak/sfjqec

Notas do Editor

  1. qualcuno NON conosce symfony?
  2. Qualcuno NON conosce jQuery?