Skip to content
Browse files

kind of got a Router working

data no longer loads, though
  • Loading branch information...
1 parent 678d1e3 commit 7aa5a1f02f3470a5766f920ff1aa77136f8d5ccc Rob Fletcher committed Jun 13, 2012
View
19 grails-app/conf/EmberScaffoldingResources.groovy
@@ -1,10 +1,23 @@
modules = {
- 'moment' {
- resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js/moment', file: 'moment.min.js']
- }
+ 'handlebars' {
+ resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js/handlebars', file: 'handlebars-1.0.0.beta.6.js']
+ }
+ 'moment' {
+ resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js/moment', file: 'moment.min.js']
+ }
'ember-scaffolding' {
dependsOn 'ember', 'moment'
resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js', file: 'scaffolding-helpers.js']
resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js', file: 'ember-scaffolding.js']
}
+ overrides {
+ 'ember' {
+ dependsOn 'jquery', 'handlebars'
+ resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js/ember', file: 'ember-latest.min.js'], nominify: true
+ }
+ 'ember-dev' {
+ dependsOn 'jquery', 'handlebars'
+ resource id: 'js', url: [plugin: 'ember-scaffolding', dir: 'js/ember', file: 'ember-latest.js'], nominify: true
+ }
+ }
}
View
22 src/templates/scaffolding/index.gsp
@@ -10,13 +10,21 @@
<r:require module="ember-scaffolding"/>
</head>
<body data-base-url="\${createLink(action: 'index')}">
- <div class="nav" role="navigation">
- <ul>
- <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
- <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
- <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
- </ul>
- </div>
+ <script type="text/x-handlebars" data-template-name="application">
+ {{view Scaffolding.NavbarView controllerBinding="controller.controllers.navbarController"}}
+ <div class="content">
+ {{outlet}}
+ </div>
+ </script>
+ <script type="text/x-handlebars" data-template-name="navbar">
+ %{--<div class="nav" role="navigation">--}%
+ <ul>
+ <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
+ <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
+ <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
+ </ul>
+ %{--</div>--}%
+ </script>
<script type="text/x-handlebars" data-template-name="list">
<h1><g:message code="default.list.label" args="[entityName]" /></h1>
<table>
View
77 web-app/js/ember-scaffolding.js
@@ -1,40 +1,61 @@
var Scaffolding = Ember.Application.create({
- baseUrl: '',
- createUrl: function(action) {
- return Scaffolding.baseUrl.replace(/index$/, action);
- }
+ baseUrl: '',
+ createUrl: function(action) {
+ return Scaffolding.baseUrl.replace(/index$/, action);
+ }
});
-Scaffolding.ListController = Ember.ArrayController.extend({});
+Scaffolding.ApplicationController = Ember.Controller.extend();
+Scaffolding.ApplicationView = Ember.View.extend({ templateName: 'application' });
+
+Scaffolding.NavbarController = Ember.Controller.extend();
+Scaffolding.NavbarView = Ember.View.extend({
+ templateName: 'navbar',
+ classNames: ['nav']
+});
+Scaffolding.ListController = Ember.ArrayController.extend({});
Scaffolding.ListView = Ember.View.extend({
- controller: Scaffolding.ListController,
- templateName: 'list'
+// controller: Scaffolding.ListController,
+ templateName: 'list',
+ classNames: ['scaffold-list']
});
-Scaffolding.listController = Scaffolding.ListController.create();
-Scaffolding.ListView.create({
- controller: Scaffolding.listController,
- classNames: ['content scaffold-list']
-}).appendTo('body');
-
-//Scaffolding.Router = Ember.Router.extend({
-// root: Ember.State.extend({
-// index: Ember.State.extend({
-// route: '/',
-// redirectsTo: 'list'
-// }),
-// list: Ember.State.extend({
-// route: '/list',
+//Scaffolding.listController = Scaffolding.ListController.create();
+//Scaffolding.ListView.create({
+// controller: Scaffolding.listController,
+// classNames: ['content scaffold-list']
+//}).appendTo('body');
+
+Scaffolding.Router = Ember.Router.extend({
+ enableLogging: true,
+ location: 'hash',
+
+ root: Ember.State.extend({
+ index: Ember.State.extend({
+ route: '/',
+ redirectsTo: 'list'
+ }),
+ list: Ember.State.extend({
+ route: '/list',
+ connectOutlets: function(router, context) {
+ var appController = router.get('applicationController');
+ appController.connectOutlet(Scaffolding.ListView);
+ },
+ setupControllers: function(manager) {
+ var listController = manager.get('listController');
+ listController.set('content', Scaffolding.List.findAll());
+ }
// controller: Scaffolding.listController
-// })
-// })
-//});
+ })
+ })
+});
$(function() {
- Scaffolding.baseUrl = $('body').data('base-url');
+ Scaffolding.baseUrl = $('body').data('base-url');
- jQuery.getJSON(Scaffolding.createUrl('list'), function(data) {
- Scaffolding.listController.set('content', data);
- });
+ Scaffolding.initialize();
+// jQuery.getJSON(Scaffolding.createUrl('list'), function(data) {
+// Scaffolding.listController.set('content', data);
+// });
});
View
18,974 web-app/js/ember/ember-latest.js
18,974 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
13 web-app/js/ember/ember-latest.min.js
13 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1,550 web-app/js/handlebars/handlebars-1.0.0.beta.6.js
1,550 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 7aa5a1f

Please sign in to comment.
Something went wrong with that request. Please try again.