Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
backbone example
<h1>Find Users</h1>
<form action="find" method="get">
<input type="text" placeholder="Enter Name" id="user-input"/>
<div id="user-selection" style="margin-top:10px;"></div>
$(function() {
var User = Backbone.Model.extend({});
var UserList = Backbone.Collection.extend({
model: User,
url: '/users.json',
parse: function(response) {
return response;
var SelectionView = Backbone.View.extend({
render: function() {
$('#user-selection').html(($(this.el).html("You Selected : " + this.model.get('name'))));
return this;
var users = new UserList();
users.fetch({async: false});
var userNames = users.pluck("name");
source : userNames,
minLength : 2,
select: function(event, ui){
var selectedModel = users.where({name: ui.item.value})[0];
var view = new SelectionView({model: selectedModel});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.