SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
Backbone.js a través de un caso práctico



     Presentación basada en el curso
 Introducción a Backbone.js de easynube




Consíguelo gratis en easynube.com
Backbone.js a través de un caso práctico




Backbone.js a travé s
 de un caso práctico
Backbone.js a través de un caso práctico




Aplicación

                       Una tienda de libros
                       en la cual se pueden
                       examinar los
                       detalles de cada libro
                       y añadirlos a una
                       lista de deseos.

                       Dentro de la lista
                       será posible visitar
                       los libros con un click
                       así como eliminarlos
                       de la lista.
Backbone.js a través de un caso práctico




Aplicación

                       Una tienda de libros
                       en la cual se pueden
                       examinar los
                       detalles de cada libro
                       y añadirlos a una
                       lista de deseos.

                       Dentro de la lista
                       será posible visitar
                       los libros con un click
                       así como eliminarlos
                       de la lista.
Backbone.js a través de un caso práctico




                  Backbone.Model


“Models are the heart of any      Los Modelos son el corazón de
JavaScript application,           cualquier aplicación javascript;
containing the interactive data   contienen la información con la
as well as a large part of the    cual se interactúa y una gran
logic surrounding it:             parte de la lógica que la rodea:
conversions, validations,         conversiones, validaciones,
computed properties, and          propiedades y control de
access control.”                  acceso.
Backbone.js a través de un caso práctico




             Backbone.Model
En la práctica:

                  Título: Programming Python
                  Autor: Mark Lutz
                  Resumen: ...


                  Backbone.Model.extend({
                      título: 'Programming Python',
                      autor: 'Mark Lutz',
                      sumario: '…'
                  });
Backbone.js a través de un caso práctico




              Backbone.Collection


Collections are ordered sets of   Las colecciones son grupos
models. You can bind "change"     ordenados de modelos. Puedes
events to be notified when        ligar los eventos 'change' para
any model in the collection has   notificar cuando se produzca un
been modified, listen for "add"   cambio en un modelo, escuchar
and "remove" events, fetch        eventos 'add' y 'remove',
the collection from the server    recuperar la colección del
[ ...]                            servidor [...]
Backbone.js a través de un caso práctico




          Backbone.Collection
En la práctica:
                  // Inicializar
                  Backbone.Collection.reset({
                       título: 'Programming Python',
                       autor: 'Mark Lutz',
                       sumario: '…'
                  });

                  // desde servidor
                  Backbone.Collection.fetch();

                  // ops
                  Backbone.Collection.get(id)

                  // eventos [add, remove, reset...]
                  Backbone.Collection.bind('add'
                  function() {});
Backbone.js a través de un caso práctico




                   Backbone.View


The general idea is to organize   La idea principal es organizar tu
your interface into logical       interfaz en vistas lógicas,
views, backed by models, each     conectadas a sus respectivos
of which can be updated           modelos, y que cada una de las
independently when the model      cuáles pueda actualizarse
changes, without having to        independientemente cuando su
redraw the page.                  modelo cambie, sin tener que
                                  actualizar la página completa.
Backbone.js a través de un caso práctico




                Backbone.View




Backbone.View.extend({                        Backbone.View.extend({
    el: $('#detail'),                             className: 'book',
    Events: {                                     render: function() {
          “click #corazon”: “add_wishlist”             $(this.el).html(
    },                                                      _.template(
    add_wishlist: function() {                                     this.model.toJSON()
          Wishlist.add(this.model);                         ))
    }                                             };
});                                           });
Backbone.js a través de un caso práctico




                   Backbone.View
      Una vista (view) de Backbone siempre tiene un elemento DOM,
                     se haya insertado en la página o no.



Backbone.view.el                   El elemento por defecto es
                                   <div>
Backbone.view.el = $               Se puede definir un elemento
('#sidebar')                       existente
Backbone.view.tagName =            Se puede elegir el tipo de elemento
“ span”
Backbone.view.className =          Se puede definir un elemento con clase
“ book”                            (<div class=”book”>)


Backbone.view.id =                 Se puede definir un elemento con id
“ book”                            (<div id=”book”>)
Backbone.js a través de un caso práctico




                 Backbone.Router


Backbone.Router provides          Backbone.Router ofrece
methods for routing client-side   métodos para trabajar con rutas
pages, and connecting them to     en el lado del cliente,
actions and events.               conectándolas con acciones y
                                  eventos.
Backbone.js a través de un caso práctico




    Backbone.Router
    Backbone.Router.extend({
       routes: {
           '':        'index',
           ':book':   'see_detail'
       }
    })




                                     URL:
URL: /                               /#3

index()                       see_detail(book)
                              /* book = 3 */
Implementa esta aplicación a través del curso
Introducción a Backbone.js de easynube:




     Consíguelo gratis en easynube.com

Más contenido relacionado

Último

BUSCADORES DE INTERNET (Universidad de Sonora).
BUSCADORES DE INTERNET (Universidad de Sonora).BUSCADORES DE INTERNET (Universidad de Sonora).
BUSCADORES DE INTERNET (Universidad de Sonora).jcaballerosamayoa
 
Gestión de concurrencia y bloqueos en SQL Server
Gestión de concurrencia y bloqueos en SQL ServerGestión de concurrencia y bloqueos en SQL Server
Gestión de concurrencia y bloqueos en SQL ServerRobertoCarrancioFern
 
Navegadores de internet - Nuevas Tecnologías de la Información y la Comunicación
Navegadores de internet - Nuevas Tecnologías de la Información y la ComunicaciónNavegadores de internet - Nuevas Tecnologías de la Información y la Comunicación
Navegadores de internet - Nuevas Tecnologías de la Información y la ComunicaciónAntonia Yamilet Perez Palomares
 
Presentacion y Extension de tema para Blogger.pptx
Presentacion y Extension de tema para Blogger.pptxPresentacion y Extension de tema para Blogger.pptx
Presentacion y Extension de tema para Blogger.pptxTaim11
 
Inteligencia Artificial para usuarios nivel inicial
Inteligencia Artificial para usuarios nivel inicialInteligencia Artificial para usuarios nivel inicial
Inteligencia Artificial para usuarios nivel inicialEducática
 
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...Kevin Serna
 
Unidad 1- Historia y Evolucion de las computadoras.pdf
Unidad 1- Historia y Evolucion de las computadoras.pdfUnidad 1- Historia y Evolucion de las computadoras.pdf
Unidad 1- Historia y Evolucion de las computadoras.pdfMarianneBAyn
 
Introducción a la robótica con arduino..pptx
Introducción a la robótica con arduino..pptxIntroducción a la robótica con arduino..pptx
Introducción a la robótica con arduino..pptxJohanna4222
 
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...Sistemas distribuidos de redes de computadores en un entorno virtual de apren...
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...Luis Fernando Uribe Villamil
 
Herramientas informáticas. Sara Torres R.
Herramientas informáticas. Sara Torres R.Herramientas informáticas. Sara Torres R.
Herramientas informáticas. Sara Torres R.saravalentinat22
 
proyectos_social_y_socioproductivos _mapas_conceptuales
proyectos_social_y_socioproductivos _mapas_conceptualesproyectos_social_y_socioproductivos _mapas_conceptuales
proyectos_social_y_socioproductivos _mapas_conceptualesssuserbe0d1c
 
manual-de-oleohidraulica-industrial-vickers.pdf
manual-de-oleohidraulica-industrial-vickers.pdfmanual-de-oleohidraulica-industrial-vickers.pdf
manual-de-oleohidraulica-industrial-vickers.pdfprofmartinsuarez
 
taller de tablas en word para estudiantes de secundaria
taller de tablas en word para estudiantes de secundariataller de tablas en word para estudiantes de secundaria
taller de tablas en word para estudiantes de secundariaandresingsiseo
 
¡Mira mi nuevo diseño hecho en Canva!.pdf
¡Mira mi nuevo diseño hecho en Canva!.pdf¡Mira mi nuevo diseño hecho en Canva!.pdf
¡Mira mi nuevo diseño hecho en Canva!.pdf7adelosriosarangojua
 
lenguaje algebraico.pptx álgebra, trigonometria
lenguaje algebraico.pptx álgebra, trigonometrialenguaje algebraico.pptx álgebra, trigonometria
lenguaje algebraico.pptx álgebra, trigonometriasofiasonder
 
Uso de las TIC en la vida cotidiana .
Uso de las TIC en la vida cotidiana       .Uso de las TIC en la vida cotidiana       .
Uso de las TIC en la vida cotidiana .itzyrivera61103
 
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUAL
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUALJORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUAL
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUALGuadalinfoHuscarGuad
 
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .llocllajoaquinci00
 
editorial de informática de los sueños.docx
editorial de informática de los sueños.docxeditorial de informática de los sueños.docx
editorial de informática de los sueños.docxssusere34b451
 
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiCVelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC6dwwcgtpfx
 

Último (20)

BUSCADORES DE INTERNET (Universidad de Sonora).
BUSCADORES DE INTERNET (Universidad de Sonora).BUSCADORES DE INTERNET (Universidad de Sonora).
BUSCADORES DE INTERNET (Universidad de Sonora).
 
Gestión de concurrencia y bloqueos en SQL Server
Gestión de concurrencia y bloqueos en SQL ServerGestión de concurrencia y bloqueos en SQL Server
Gestión de concurrencia y bloqueos en SQL Server
 
Navegadores de internet - Nuevas Tecnologías de la Información y la Comunicación
Navegadores de internet - Nuevas Tecnologías de la Información y la ComunicaciónNavegadores de internet - Nuevas Tecnologías de la Información y la Comunicación
Navegadores de internet - Nuevas Tecnologías de la Información y la Comunicación
 
Presentacion y Extension de tema para Blogger.pptx
Presentacion y Extension de tema para Blogger.pptxPresentacion y Extension de tema para Blogger.pptx
Presentacion y Extension de tema para Blogger.pptx
 
Inteligencia Artificial para usuarios nivel inicial
Inteligencia Artificial para usuarios nivel inicialInteligencia Artificial para usuarios nivel inicial
Inteligencia Artificial para usuarios nivel inicial
 
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...
HerramientasInformaticas ¿Que es? - ¿Para que sirve? - Recomendaciones - Comp...
 
Unidad 1- Historia y Evolucion de las computadoras.pdf
Unidad 1- Historia y Evolucion de las computadoras.pdfUnidad 1- Historia y Evolucion de las computadoras.pdf
Unidad 1- Historia y Evolucion de las computadoras.pdf
 
Introducción a la robótica con arduino..pptx
Introducción a la robótica con arduino..pptxIntroducción a la robótica con arduino..pptx
Introducción a la robótica con arduino..pptx
 
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...Sistemas distribuidos de redes de computadores en un entorno virtual de apren...
Sistemas distribuidos de redes de computadores en un entorno virtual de apren...
 
Herramientas informáticas. Sara Torres R.
Herramientas informáticas. Sara Torres R.Herramientas informáticas. Sara Torres R.
Herramientas informáticas. Sara Torres R.
 
proyectos_social_y_socioproductivos _mapas_conceptuales
proyectos_social_y_socioproductivos _mapas_conceptualesproyectos_social_y_socioproductivos _mapas_conceptuales
proyectos_social_y_socioproductivos _mapas_conceptuales
 
manual-de-oleohidraulica-industrial-vickers.pdf
manual-de-oleohidraulica-industrial-vickers.pdfmanual-de-oleohidraulica-industrial-vickers.pdf
manual-de-oleohidraulica-industrial-vickers.pdf
 
taller de tablas en word para estudiantes de secundaria
taller de tablas en word para estudiantes de secundariataller de tablas en word para estudiantes de secundaria
taller de tablas en word para estudiantes de secundaria
 
¡Mira mi nuevo diseño hecho en Canva!.pdf
¡Mira mi nuevo diseño hecho en Canva!.pdf¡Mira mi nuevo diseño hecho en Canva!.pdf
¡Mira mi nuevo diseño hecho en Canva!.pdf
 
lenguaje algebraico.pptx álgebra, trigonometria
lenguaje algebraico.pptx álgebra, trigonometrialenguaje algebraico.pptx álgebra, trigonometria
lenguaje algebraico.pptx álgebra, trigonometria
 
Uso de las TIC en la vida cotidiana .
Uso de las TIC en la vida cotidiana       .Uso de las TIC en la vida cotidiana       .
Uso de las TIC en la vida cotidiana .
 
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUAL
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUALJORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUAL
JORNADA INTELIGENCIA ARTIFICIAL Y REALIDAD VIRTUAL
 
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .
CIBERSEGURIDAD Y SEGURIDAD INFORMATICA .
 
editorial de informática de los sueños.docx
editorial de informática de los sueños.docxeditorial de informática de los sueños.docx
editorial de informática de los sueños.docx
 
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiCVelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC
VelderrainPerez_Paola_M1C1G63-097.pptx. LAS TiC
 

Destacado

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Introducción a Backbone.js con un caso práctico - easynube

  • 1. Backbone.js a través de un caso práctico Presentación basada en el curso Introducción a Backbone.js de easynube Consíguelo gratis en easynube.com
  • 2. Backbone.js a través de un caso práctico Backbone.js a travé s de un caso práctico
  • 3. Backbone.js a través de un caso práctico Aplicación Una tienda de libros en la cual se pueden examinar los detalles de cada libro y añadirlos a una lista de deseos. Dentro de la lista será posible visitar los libros con un click así como eliminarlos de la lista.
  • 4. Backbone.js a través de un caso práctico Aplicación Una tienda de libros en la cual se pueden examinar los detalles de cada libro y añadirlos a una lista de deseos. Dentro de la lista será posible visitar los libros con un click así como eliminarlos de la lista.
  • 5. Backbone.js a través de un caso práctico Backbone.Model “Models are the heart of any Los Modelos son el corazón de JavaScript application, cualquier aplicación javascript; containing the interactive data contienen la información con la as well as a large part of the cual se interactúa y una gran logic surrounding it: parte de la lógica que la rodea: conversions, validations, conversiones, validaciones, computed properties, and propiedades y control de access control.” acceso.
  • 6. Backbone.js a través de un caso práctico Backbone.Model En la práctica: Título: Programming Python Autor: Mark Lutz Resumen: ... Backbone.Model.extend({ título: 'Programming Python', autor: 'Mark Lutz', sumario: '…' });
  • 7. Backbone.js a través de un caso práctico Backbone.Collection Collections are ordered sets of Las colecciones son grupos models. You can bind "change" ordenados de modelos. Puedes events to be notified when ligar los eventos 'change' para any model in the collection has notificar cuando se produzca un been modified, listen for "add" cambio en un modelo, escuchar and "remove" events, fetch eventos 'add' y 'remove', the collection from the server recuperar la colección del [ ...] servidor [...]
  • 8. Backbone.js a través de un caso práctico Backbone.Collection En la práctica: // Inicializar Backbone.Collection.reset({ título: 'Programming Python', autor: 'Mark Lutz', sumario: '…' }); // desde servidor Backbone.Collection.fetch(); // ops Backbone.Collection.get(id) // eventos [add, remove, reset...] Backbone.Collection.bind('add' function() {});
  • 9. Backbone.js a través de un caso práctico Backbone.View The general idea is to organize La idea principal es organizar tu your interface into logical interfaz en vistas lógicas, views, backed by models, each conectadas a sus respectivos of which can be updated modelos, y que cada una de las independently when the model cuáles pueda actualizarse changes, without having to independientemente cuando su redraw the page. modelo cambie, sin tener que actualizar la página completa.
  • 10. Backbone.js a través de un caso práctico Backbone.View Backbone.View.extend({ Backbone.View.extend({ el: $('#detail'), className: 'book', Events: { render: function() { “click #corazon”: “add_wishlist” $(this.el).html( }, _.template( add_wishlist: function() { this.model.toJSON() Wishlist.add(this.model); )) } }; }); });
  • 11. Backbone.js a través de un caso práctico Backbone.View Una vista (view) de Backbone siempre tiene un elemento DOM, se haya insertado en la página o no. Backbone.view.el El elemento por defecto es <div> Backbone.view.el = $ Se puede definir un elemento ('#sidebar') existente Backbone.view.tagName = Se puede elegir el tipo de elemento “ span” Backbone.view.className = Se puede definir un elemento con clase “ book” (<div class=”book”>) Backbone.view.id = Se puede definir un elemento con id “ book” (<div id=”book”>)
  • 12. Backbone.js a través de un caso práctico Backbone.Router Backbone.Router provides Backbone.Router ofrece methods for routing client-side métodos para trabajar con rutas pages, and connecting them to en el lado del cliente, actions and events. conectándolas con acciones y eventos.
  • 13. Backbone.js a través de un caso práctico Backbone.Router Backbone.Router.extend({ routes: { '': 'index', ':book': 'see_detail' } }) URL: URL: / /#3 index() see_detail(book) /* book = 3 */
  • 14. Implementa esta aplicación a través del curso Introducción a Backbone.js de easynube: Consíguelo gratis en easynube.com