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
/* ============================================================= | |
* bootstrap-typeahead-backbone.js v2.0.0 | |
* http://twitter.github.com/bootstrap/javascript.html#typeahead | |
* https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js | |
* Modified by Marius Andreiana to work with Backbone Collection, Model, View | |
* - custom results formatting | |
* - custom behavior on selected item (Model with complex information) | |
* ============================================================= | |
* Copyright 2012 Twitter, Inc. | |
* |
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
/* ============================================================= | |
* bootstrap-typeahead-backbone.js v2.0.0 | |
* http://twitter.github.com/bootstrap/javascript.html#typeahead | |
* https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js | |
* Modified by Marius Andreiana to work with Backbone Collection, Model, View | |
* - custom results formatting | |
* - custom behavior on selected item (Model with complex information) | |
* ============================================================= | |
* Copyright 2012 Twitter, Inc. | |
* |
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
/* ============================================================= | |
* bootstrap-typeahead-backbone.js v2.0.0 | |
* http://twitter.github.com/bootstrap/javascript.html#typeahead | |
* https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js | |
* Modified by Marius Andreiana to work with Backbone Collection, Model, View | |
* - custom results formatting | |
* - custom behavior on selected item (Model with complex information) | |
* ============================================================= | |
* Copyright 2012 Twitter, Inc. | |
* |
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
class TypeaheadView extends Backbone.View | |
tagName: 'input' | |
initialize: (@options) -> | |
@source = options.source if options.source? | |
@ | |
# Retrieves the Backbone Model that matches this view's value | |
# Will have problems if you have multiple Models with the same attribute that | |
# you are using as the typeahead's source. | |
getModel: () -> |
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
var Autocomplete = Backbone.View.extend({ | |
render: function() { | |
var choices = this.options.choices, | |
selected = this.options.selected, | |
iterator = this.options.iterator, | |
label = this.options.label, | |
allowDupes = this.options.allowDupes, | |
$el = $(this.el); | |
$el.autocomplete({ | |
source: function(request, response) { |