Last active
December 14, 2015 15:59
-
-
Save juandazapata/5112174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template = require 'views/templates/hostels/search' | |
| CollectionView= require 'views/base/collection-view' | |
| HostelItemView = require 'views/hostels/item' | |
| module.exports = class HostelSearchView extends CollectionView | |
| className: 'search-results' | |
| itemView: HostelItemView | |
| template: template | |
| listSelector: '.hostels' | |
| fallbackSelector: '.empty-message' | |
| loadingSelector: '.loading' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Collection = require 'models/base/collection' | |
| Hostel = require 'models/hostels/item' | |
| config = require 'config' | |
| mediator = require 'mediator' | |
| _ = require 'underscore' | |
| module.exports = class HostelsCollection extends Collection | |
| model: Hostel | |
| url: "#{config.API_URL}/hostels/search.json" | |
| parse: (response) -> | |
| arr = new Array() | |
| _.each(response.hostels, (elem) -> | |
| arr.push(elem.hostel) | |
| ) | |
| arr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Controller = require 'controllers/base/controller' | |
| HostelShowView = require 'views/hostels/show' | |
| HostelSearchView = require 'views/hostels/search' | |
| HostelsCollection = require 'models/hostels/hostels-collection' | |
| module.exports = class HostelsController extends Controller | |
| search: -> | |
| @publishEvent '!adjustTitle', 'Hostel search results' | |
| @collection = new HostelsCollection() | |
| @collection.fetch() | |
| @view = new HostelSearchView(collection: @collection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment