2013-09-22 07:55:44 +00:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'app',
|
|
|
|
'Series/SeriesCollection'
|
|
|
|
], function (App, SeriesCollection) {
|
|
|
|
$.fn.bindSearch = function () {
|
|
|
|
$(this).typeahead({
|
|
|
|
source : function () {
|
2013-09-23 19:03:33 +00:00
|
|
|
return SeriesCollection.pluck('title');
|
2013-09-22 07:55:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
sorter: function (items) {
|
|
|
|
return items.sort();
|
|
|
|
},
|
|
|
|
|
|
|
|
updater: function (item) {
|
2013-09-23 19:03:33 +00:00
|
|
|
var series = SeriesCollection.findWhere({ title: item });
|
2013-09-22 07:55:44 +00:00
|
|
|
|
|
|
|
this.$element.blur();
|
|
|
|
App.Router.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|