Skip to content

Instantly share code, notes, and snippets.

@AgileMantis
Created July 7, 2012 13:50
Show Gist options
  • Save AgileMantis/3066538 to your computer and use it in GitHub Desktop.
Save AgileMantis/3066538 to your computer and use it in GitHub Desktop.
Ember.RadioButtonGroup html test file
<html>
<head>
<script type='text/javascript' src='../../jayferd/ember.js/lib/jquery-1.7.2.js' ></script>
<script type='text/javascript' src='../../jayferd/ember.js/lib/handlebars-1.0.0.beta.6.js' ></script>
<script type='text/javascript' src='../../jayferd/ember.js/dist/ember.js' ></script>
</head>
<body>
<script type='text/javascript'>
window.App = Ember.Application.create();
App.question = Ember.Object.create({
content: "Which of the following is the largest?",
possibleAnswers: [
Ember.Object.create({ label: "A peanut", value: "peanut" }),
Ember.Object.create({ label: "An elephant", value: "elephant" }),
Ember.Object.create({ label: "The moon", value: "moon" }),
Ember.Object.create({ label: "A tennis ball", value: "tennis ball" })
],
selectedAnswer: "moon"
});
App.questionView = Ember.View.create({
templateName: "questionView",
questionBinding: "App.question"
});
$(function() {
App.questionView.append();
// Change answer to test bindings post DOM insert
// App.question.selectedAnswer = "tennis ball";
});
</script>
<script type="text/x-handlebars" data-template-name="questionView" >
{{#view Ember.RadioButtonGroup name="answer" selectedValueBinding="App.question.selectedAnswer"}}
{{view selection="moon"}}
{{question.content}}
{{#each question.possibleAnswers}}
{{label}}
{{view view.RadioButton value=value}}
{{/each}}
{{/view}}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment