PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

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

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