class App.AutocompleteView extends Batman.View
html: "<input type='text' />"
autocompleteSource: -> []
viewDidAppear: ->
# I had to replace @node (as it is in the official documentation) to @node.firstChild since that is <input type='text' />
# @node in my experiment is <div class="large-12 columns>
$(@node.firstChild).autocomplete
source: @autocompleteSource()
HTML template:
</...
Given the following js model:
class MyApp.Post extends Batman.Model
@encode options
Given the server side json (generated with rabl):
object @post
attributes :id, :category
node(:categories) {
Category::OPTIONS.map{ |option| { id: option, name: I18n.t(option) } }
}
And finally the binded view (haml):
# This binds the selected value to the model object
%select{ "data-bind" => "post.category" }
# Iterate over categories
%option{ "data-foreach-category" =>"post.categories",
...