Created
February 28, 2014 13:43
-
-
Save karl-sjogren/9271336 to your computer and use it in GitHub Desktop.
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</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> |
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
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