Created
August 28, 2013 11:06
-
-
Save sunliwen/6364881 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.6/ember.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
{{render "autocomplete"}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="autocomplete"> | |
{{input type="text" value=searchText placeholder="Search..."}} | |
<ul> | |
{{#each searchResults}} | |
<li>{{this}}</li> | |
{{/each}} | |
</ul> | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
App = Ember.Application.create(); | |
App.AutocompleteController = Ember.Controller.extend({ | |
searchResults: function() { | |
var searchText = this.get("searchText"); | |
if(!searchText) return; | |
var regex = new RegExp(searchText, "i"); | |
return ["one", "two", "three"].filter(function(value) { | |
return value.match(regex); | |
}); | |
}.property("searchText") | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment