Created
February 18, 2014 04:21
-
-
Save eads/9064603 to your computer and use it in GitHub Desktop.
This file contains 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
<script type="text/javascript"> | |
$(document).ready(function() { | |
// Search 6 weeks back | |
var start = moment(); | |
var end = start.clone().add('months', 1).add('weeks', 2); | |
// Set up collection | |
var collection = new EventAPICollection([], { | |
url: 'http://urltoapiproxy.com/events.json', | |
indexed: false, | |
params: { | |
date_from: start.format('YYYY-MM-DD'), | |
date_to: end.format('YYYY-MM-DD'), | |
type: "Theater", | |
fields: 'event_dates,neighborhood_name,venue_name,description,url,price,title,state,city_name' | |
}, | |
}); | |
// Create an input box | |
var filter = new FilterView({ | |
el: $('#filter'), | |
collection: collection, | |
}); | |
// When collection.fetch() is called, bind to the autocomplete box | |
collection.on("sync", function() { | |
$('#filter input').attr('disabled', false); | |
filter.$input | |
.bind('typeahead:selected typeahead:autocompleted', | |
function(e, value, dataset) { | |
if (value) { | |
var val = value.value; | |
if (dataset == 'day') { | |
val = value.day; | |
} | |
val = encodeURIComponent(val); | |
window.location = "http://myeventurl.com/#" + dataset + "/" + val; | |
} | |
}) | |
; | |
}); | |
// Get the data! | |
collection.fetch(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment