Skip to content

Instantly share code, notes, and snippets.

@karl-sjogren
Created February 28, 2014 13:43
Show Gist options
  • Save karl-sjogren/9271336 to your computer and use it in GitHub Desktop.
Save karl-sjogren/9271336 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Ember</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/release/ember.js"></script>
</head>
<body>
<script type="text/x-handlebars">
<h1>Dynamicly inserted components</h1>
{{view myContainer}}
{{some-test}}
</script>
</body>
</html>
var App = Ember.Application.create();
App.ApplicationMixin = Ember.Mixin.create({
myContainer: Ember.ContainerView.create(),
actions: {
someAction: function() {
var container = this.get('myContainer');
var component = App.SomeTestComponent.create();
container.pushObject(component);
}
}
});
App.ApplicationController = Ember.ObjectController.extend(App.ApplicationMixin, {});
App.SomeTestComponent = Ember.Component.extend({
layout: Ember.Handlebars.compile('<h2>Component</h2> <button class="btn btn-primary" {{action "btnClicked"}}>Click me</button>'),
action: 'someAction',
actions: {
btnClicked: function() {
this.sendAction('action');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment