PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/practicals/modular-mobile-app/app/views/photoList.js

https://github.com/logicaroma/backbone-fundamentals
JavaScript | 33 lines | 24 code | 8 blank | 1 comment | 0 complexity | 3ba015f09f033998abdfc133f6e3e3dc MD5 | raw file
  1. define( ['jquery', 'backbone', 'underscore', 'models/PhotoCollection', 'text!templates/photoview.html'],
  2. function( $, Backbone, _ , PhotoCollection, photoTemplate) {
  3. // Using ECMAScript 5 strict mode during development. By default r.js will ignore that.
  4. "use strict";
  5. var PhotoList = Backbone.View.extend( {
  6. el: $( "#photoviewholder" ),
  7. initialize: function() {
  8. this.collection = new PhotoCollection;
  9. _.bindAll(this, "renderList");
  10. this.collection.bind( "reset", this.renderList );
  11. },
  12. renderList: function( collection ) {
  13. var compiled_template = _.template(photoTemplate),
  14. collection = this.collection,
  15. $el = $(this.el);
  16. mobileSearch.utils.loadPrompt( "Loading photo..." );
  17. $( '#photo .ui-title' ).html( 'Photo view' );
  18. $el.html( compiled_template( { results: collection.models } ) );
  19. setTimeout( function() {
  20. $el.listview('refresh');
  21. }, 0 );
  22. }
  23. } );
  24. return PhotoList;
  25. } );