Created
May 18, 2015 15:09
-
-
Save anonymous/43818393437b873ba3b4 to your computer and use it in GitHub Desktop.
Ember Starter Kit // source http://emberjs.jsbin.com/oTIxAjI/1
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ember Starter Kit</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css"> | |
<style id="jsbin-css"> | |
/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
<ul> | |
{{#each item in model}} | |
<li>{{item.color}}</li> | |
{{/each}} | |
</ul> | |
Filtered: | |
By: {{input value=daFilter}} | |
<ul> | |
{{#each item in filtered}} | |
<li>{{item.color}}</li> | |
{{/each}} | |
</ul> | |
{{auto-complete model=model filterByPath='color' visualPath='color'}} | |
</script> | |
<script type="text/x-handlebars"s data-template-name="components/auto-complete"> | |
{{input type="text" value=searchText placeholder="Search..."}} | |
<ul> | |
{{#each searchResults}} | |
<li>{{this}}</li> | |
{{/each}} | |
</ul> | |
</script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.1.2.js"></script> | |
<script src="http://builds.emberjs.com/tags/v1.2.0/ember.min.js"></script> | |
<script id="jsbin-javascript"> | |
App = Ember.Application.create(); | |
App.Router.map(function() { | |
// put your routes here | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return [{color:'red'}, {color:'yellow'}, {color:'blue'}]; | |
} | |
}); | |
App.IndexController = Em.ArrayController.extend({ | |
daFilter: 'blue', | |
filtered: function(){ | |
return this.get('model').filterBy('color', this.get('daFilter')); | |
}.property('model.@each.color', 'daFilter') | |
}); | |
App.AutoCompleteComponent = Ember.Component.extend({ | |
searchText: null, | |
searchResults: function() { | |
var model = this.get('model'); | |
var searchText = this.get('searchText'); | |
var visualPath = this.get('visualPath'); | |
console.log(this.get('model')); // shows array | |
if (searchText){ | |
console.log('searching for: ' + searchText); // shows up in console with searchText | |
var regex = new RegExp(searchText, 'i'); | |
model = model.filterBy(this.get('filterByPath'), searchText); | |
} | |
return model.getEach(visualPath); | |
}.property('searchText') | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ember Starter Kit</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css"> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
{{outlet}} | |
<\/script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
<ul> | |
{{#each item in model}} | |
<li>{{item.color}}</li> | |
{{/each}} | |
</ul> | |
Filtered: | |
By: {{input value=daFilter}} | |
<ul> | |
{{#each item in filtered}} | |
<li>{{item.color}}</li> | |
{{/each}} | |
</ul> | |
{{auto-complete model=model filterByPath='color' visualPath='color'}} | |
<\/script> | |
<script type="text/x-handlebars"s data-template-name="components/auto-complete"> | |
{{input type="text" value=searchText placeholder="Search..."}} | |
<ul> | |
{{#each searchResults}} | |
<li>{{this}}</li> | |
{{/each}} | |
</ul> | |
<\/script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"><\/script> | |
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.1.2.js"><\/script> | |
<script src="http://builds.emberjs.com/tags/v1.2.0/ember.min.js"><\/script> | |
</body> | |
</html> | |
</script> | |
<script id="jsbin-source-css" type="text/css">/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">App = Ember.Application.create(); | |
App.Router.map(function() { | |
// put your routes here | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return [{color:'red'}, {color:'yellow'}, {color:'blue'}]; | |
} | |
}); | |
App.IndexController = Em.ArrayController.extend({ | |
daFilter: 'blue', | |
filtered: function(){ | |
return this.get('model').filterBy('color', this.get('daFilter')); | |
}.property('model.@each.color', 'daFilter') | |
}); | |
App.AutoCompleteComponent = Ember.Component.extend({ | |
searchText: null, | |
searchResults: function() { | |
var model = this.get('model'); | |
var searchText = this.get('searchText'); | |
var visualPath = this.get('visualPath'); | |
console.log(this.get('model')); // shows array | |
if (searchText){ | |
console.log('searching for: ' + searchText); // shows up in console with searchText | |
var regex = new RegExp(searchText, 'i'); | |
model = model.filterBy(this.get('filterByPath'), searchText); | |
} | |
return model.getEach(visualPath); | |
}.property('searchText') | |
});</script></body> | |
</html> |
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
/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
} |
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
App = Ember.Application.create(); | |
App.Router.map(function() { | |
// put your routes here | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return [{color:'red'}, {color:'yellow'}, {color:'blue'}]; | |
} | |
}); | |
App.IndexController = Em.ArrayController.extend({ | |
daFilter: 'blue', | |
filtered: function(){ | |
return this.get('model').filterBy('color', this.get('daFilter')); | |
}.property('model.@each.color', 'daFilter') | |
}); | |
App.AutoCompleteComponent = Ember.Component.extend({ | |
searchText: null, | |
searchResults: function() { | |
var model = this.get('model'); | |
var searchText = this.get('searchText'); | |
var visualPath = this.get('visualPath'); | |
console.log(this.get('model')); // shows array | |
if (searchText){ | |
console.log('searching for: ' + searchText); // shows up in console with searchText | |
var regex = new RegExp(searchText, 'i'); | |
model = model.filterBy(this.get('filterByPath'), searchText); | |
} | |
return model.getEach(visualPath); | |
}.property('searchText') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment