SlideShare a Scribd company logo
JavaScriptMVC Es un framework  basado  en JQuery para crear RIA.
JavaScriptMVC JavaScript puro
document.getElementById("box").style.display = "block";
JavaScriptMVC JavaScript con librerías
$(”box”).attr(”display ”, ”block”);
$(”box”).show();
JavaScriptMVC JavaScript con framework
jQuery.Controller.extend('BoxController', {},
{
init: function (el) {
this._super(el); this.element.show(); }
} );
JavaScriptMVC Conclusión:  No uses JavaScript para mostrar una cajita
JavaScriptMVC Un ejemplo:  Simple Gallery
Una aplicación donde buscas imagenes en Flickr y las agregas a tu galería donde podes acomodarlas.
Vamos a ver como hacemos lo mismo con  y sin JavaScriptMVC
Ad

More Related Content

What's hot (20)

Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)
Marco Cedaro
 
An introduction to Ember framework
An introduction to Ember frameworkAn introduction to Ember framework
An introduction to Ember framework
Diana Falkowska
 
Crea un tema compatibile con le ultime novità WordPress
Crea un tema compatibile con le ultime novità WordPressCrea un tema compatibile con le ultime novità WordPress
Crea un tema compatibile con le ultime novità WordPress
SkillsAndMore
 
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Ontico
 
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
irwinvifxcfesre
 
Prototype UI
Prototype UIPrototype UI
Prototype UI
Sébastien Gruhier
 
Animação com jQuery
Animação com jQueryAnimação com jQuery
Animação com jQuery
douglasgrava
 
噗浪最近有點胖
噗浪最近有點胖噗浪最近有點胖
噗浪最近有點胖
Irvin Chen
 
Twig, los mejores trucos y técnicas avanzadas
Twig, los mejores trucos y técnicas avanzadasTwig, los mejores trucos y técnicas avanzadas
Twig, los mejores trucos y técnicas avanzadas
Javier Eguiluz
 
jQuery Plugins Intro
jQuery Plugins IntrojQuery Plugins Intro
jQuery Plugins Intro
Casey West
 
Introduction à Marionette
Introduction à MarionetteIntroduction à Marionette
Introduction à Marionette
Raphaël Lemaire
 
Angular 2のRenderer
Angular 2のRendererAngular 2のRenderer
Angular 2のRenderer
Yosuke Onoue
 
WordPress Customizer
WordPress CustomizerWordPress Customizer
WordPress Customizer
slicejack
 
JQuery应用开发
JQuery应用开发JQuery应用开发
JQuery应用开发
chevionlu
 
Templating WordPress
Templating WordPressTemplating WordPress
Templating WordPress
Konstantin Kovshenin
 
UISearchController par Stéphane sudre
UISearchController par Stéphane sudreUISearchController par Stéphane sudre
UISearchController par Stéphane sudre
CocoaHeads France
 
JSF 2 and Ajax
JSF 2 and  AjaxJSF 2 and  Ajax
JSF 2 and Ajax
Jim Driscoll
 
Chief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for KeefChief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for Keef
chicagonewsonlineradio
 
Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)
Marco Cedaro
 
An introduction to Ember framework
An introduction to Ember frameworkAn introduction to Ember framework
An introduction to Ember framework
Diana Falkowska
 
Crea un tema compatibile con le ultime novità WordPress
Crea un tema compatibile con le ultime novità WordPressCrea un tema compatibile con le ultime novità WordPress
Crea un tema compatibile con le ultime novità WordPress
SkillsAndMore
 
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Angular 2 не так уж и плох... А если задуматься, то и просто хорош / Алексей ...
Ontico
 
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
irwinvifxcfesre
 
Animação com jQuery
Animação com jQueryAnimação com jQuery
Animação com jQuery
douglasgrava
 
噗浪最近有點胖
噗浪最近有點胖噗浪最近有點胖
噗浪最近有點胖
Irvin Chen
 
Twig, los mejores trucos y técnicas avanzadas
Twig, los mejores trucos y técnicas avanzadasTwig, los mejores trucos y técnicas avanzadas
Twig, los mejores trucos y técnicas avanzadas
Javier Eguiluz
 
jQuery Plugins Intro
jQuery Plugins IntrojQuery Plugins Intro
jQuery Plugins Intro
Casey West
 
Introduction à Marionette
Introduction à MarionetteIntroduction à Marionette
Introduction à Marionette
Raphaël Lemaire
 
Angular 2のRenderer
Angular 2のRendererAngular 2のRenderer
Angular 2のRenderer
Yosuke Onoue
 
WordPress Customizer
WordPress CustomizerWordPress Customizer
WordPress Customizer
slicejack
 
JQuery应用开发
JQuery应用开发JQuery应用开发
JQuery应用开发
chevionlu
 
UISearchController par Stéphane sudre
UISearchController par Stéphane sudreUISearchController par Stéphane sudre
UISearchController par Stéphane sudre
CocoaHeads France
 
Chief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for KeefChief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for Keef
chicagonewsonlineradio
 

Viewers also liked (8)

Le pic de Hubert
Le pic de HubertLe pic de Hubert
Le pic de Hubert
acrespel
 
X efficiency of commercial banks in kenya
X efficiency of commercial banks in kenyaX efficiency of commercial banks in kenya
X efficiency of commercial banks in kenya
Alexander Decker
 
Marketing Segmentation
Marketing SegmentationMarketing Segmentation
Marketing Segmentation
Karthik Shakthi
 
Vero
VeroVero
Vero
Refuerzo
 
Analytics services 2013
Analytics services 2013Analytics services 2013
Analytics services 2013
Afsar Ali
 
Zakah
ZakahZakah
Zakah
16dnh
 
Introduction of gastrointestinal tract
Introduction of gastrointestinal tractIntroduction of gastrointestinal tract
Introduction of gastrointestinal tract
Rajesh Goit
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
Amandeep Kaur
 
Le pic de Hubert
Le pic de HubertLe pic de Hubert
Le pic de Hubert
acrespel
 
X efficiency of commercial banks in kenya
X efficiency of commercial banks in kenyaX efficiency of commercial banks in kenya
X efficiency of commercial banks in kenya
Alexander Decker
 
Analytics services 2013
Analytics services 2013Analytics services 2013
Analytics services 2013
Afsar Ali
 
Zakah
ZakahZakah
Zakah
16dnh
 
Introduction of gastrointestinal tract
Introduction of gastrointestinal tractIntroduction of gastrointestinal tract
Introduction of gastrointestinal tract
Rajesh Goit
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
Amandeep Kaur
 
Ad

JavascriptMVC

  • 1. JavaScriptMVC Es un framework basado en JQuery para crear RIA.
  • 9. {
  • 12. } );
  • 13. JavaScriptMVC Conclusión: No uses JavaScript para mostrar una cajita
  • 14. JavaScriptMVC Un ejemplo: Simple Gallery
  • 15. Una aplicación donde buscas imagenes en Flickr y las agregas a tu galería donde podes acomodarlas.
  • 16. Vamos a ver como hacemos lo mismo con y sin JavaScriptMVC
  • 17. (sin framework pero con JQuery, tampoco tengo tanto tiempo libre che!)
  • 18. JavaScriptMVC ¿Cómo harían esta aplicación?
  • 19. JavaScriptMVC $( function () { // load $.get( &quot;/server/get.php&quot; , function (images) { for ( var i = 0; i < images.length; i++) { addImageToGallery(images[i]); } }, &quot;json&quot; ); }); function addImageToGallery(data) { var link, img, li; link = $( &quot;<a></a>&quot; ).attr( &quot;href&quot; , data.src.replace( /_m\./ , &quot;.&quot; )); img = data; img.alt = img.title; img.src = data.src.replace( /_m\./ , &quot;_s.&quot; ); li = $( &quot;<li></li>&quot; ).attr( &quot;id&quot; , &quot;image_item_&quot; + data.id); delete img.id; link.append($( &quot;<img />&quot; ).attr(img)); link.lightBox({eventType: &quot;dblclick&quot; }); li.append(link); $( &quot;#gallery&quot; ).append(li); }
  • 21. JavaScriptMVC $ ./js jmvc/generate/controller Gallery /** * @tag controllers, home */ jQuery.Controller.extend( 'GalleryController' , /* @Static */ { }, /* @Prototype */ { init: function (el) { this ._super(el); ImageItem.findAll( this .callback( function (images) { for ( var i = 0; i < images.length; i++) { this .addImage(images[i]); } })); }, addImage: function (image) { this .element.append( this .view( 'image' , {image: image})); } }); // $(”#gallery”).gallery_controller() El controlador
  • 22. JavaScriptMVC Creamos el archivo /views/gallery/image.ejs <li id=&quot; <%= image.identity() %> &quot;> <a href=&quot; <%= image.getFull() %> &quot; title=&quot; <%= image.title %> &quot;> <img src=&quot; <%= image.getThumb() %> &quot; alt=&quot; <%= image.title %> &quot; /> </a> </li> La vista
  • 23. JavaScriptMVC $ ./js jmvc/generate/model ImageItem $.Model.extend( 'ImageItem' , /* @Static */ { findAll: function (success) { $.ajax({ url: &quot;/server/get.php&quot; , type: 'get' , success: this .callback([ &quot;wrapMany&quot; , success]), dataType: &quot;json&quot; }); }, }, /* @Prototype */ { getThumb: function () { return this .src.replace( /_m\./ , '_s.' ); }, getFull: function () { return this .src.replace( /_m\./ , '.' ); } }) El modelo
  • 24. JavaScriptMVC $( &quot;#search form&quot; ).submit( function (event) { event.preventDefault(); flickrSearch($( this .q).val(), function (items) { var html = &quot;<ul>&quot; ; var item; for ( var i = 0; i < items.length; i++) { item = items[i]; html += &quot;<li title=\&quot;Click to add\&quot;><img src='&quot; + item.media.m + &quot;' />&quot; ; html += &quot;<p>&quot; + item.title + &quot;</p></li>&quot; ; } html += &quot;</ul>&quot; ; $( &quot;#search_results&quot; ).html(html); $( &quot;#search_results&quot; ).show(); }); return false ; }); $( &quot;#toggle_results&quot; ).click( function () { $( &quot;#search_results&quot; ).toggle(); }); $( &quot;#search_results li&quot; ).live( &quot;click&quot; , function () { var o = { src: $( &quot;img&quot; , this ).attr( &quot;src&quot; ), title: $( &quot;p&quot; , this ).html() }; $.post( &quot;/server/save.php&quot; , o, function (response) { addImageToGallery(response); }, &quot;json&quot; ); $( &quot;#search_results&quot; ).hide(); });
  • 25. JavaScriptMVC jQuery.Controller.extend( 'SearchController' , {}, { &quot;form submit&quot; : function (el, ev) { ev.preventDefault(); Flickr.search( this .element.find( &quot;input&quot; ).val(), this .callback( &quot;showResults&quot; )); }, showResults: function (results) { var html = this .view( &quot;results&quot; , {results: results}); $( &quot;#search_results&quot; ).html(html).show(); }, &quot;#toggle_results a click&quot; : function (el, ev) { $( &quot;#search_results&quot; ).toggle(); ev.preventDefault(); }, &quot;#search_results li click&quot; : function (el) { var image = new ImageItem({ src: $( &quot;img&quot; , el).attr( &quot;src&quot; ), title: $( &quot;p&quot; , el).html() }); image.save( function (imageModel) { $( &quot;#gallery&quot; ).controller().addImage(imageModel); }); $( &quot;#search_results&quot; ).hide(); } });
  • 27. JavaScriptMVC Follow me @4lb0 / http://albo.me
  翻译: