I have been looking at the various marionette questions and not found what i'm after and was hoping someone could give me some sound advice and a couple pointers. I am new to this and just looking to build on the boilerplate starter pack i selected on github
https://github.com/coombsj/RequireJS-BackboneJs-MarionetteJS-Bootstrap_Starter
I would like to establish two things;
- how to create routes & contoller config for the afor referenced project - please see examples explained below.??
- using the same referenced project how do i include or use jquery within a template page, anything such as page document ready so show an alert box??
It has a navigation structure in it and a couple regions defined which i get but other than the LandingView.html the navigation doesn't load any pages in contentRegion.
This appears to be down to now template pages created (handlebars), i'm ok with them but struggling to create the routes and controller section correctly.
at the moment, the Router.js looks like this
define(['marionette', 'app/Controller'],
function (marionette, Controller) {
'use strict';
return marionette.AppRouter.extend({
appRoutes: {
'test' : 'testView',
'*action' : 'logAction'
},
controller: Controller
});
});
and the Controller.js
define(['app/views/LandingView'],
function (LandingView) {
"use strict";
return {
logAction: function (action) {
console.log(action);
S2C.content.show(new LandingView());
}
};
});
define(['app/views/testView'],
function (testView) {
"use strict";
return {
testView: function (test) {
console.log(action);
S2C.content.show(new testView());
}
};
});
the LandingPage loads ok
LandingView.js
define(['marionette', 'tpl!app/views/_templates/LandingView.html'],
function (Marionette, template) {
"use strict";
return Marionette.ItemView.extend({
template: template()
});
});
LandingView.html
<div style="background-color:#6CF">
<h2>
This is the home page
</h2>
</div>
my testView does not load
testView.js
define(['marionette', 'tpl!app/views/_templates/testView.html'],
function (Marionette, template) {
"use strict";
return Marionette.ItemView.extend({
template: template()
});
});
testView.html
<form class="form-inline" id="testForm" method="post" action="#">
<div>
<input type="text" name="name" accesskey="s" size="30"
value=""/>
<input type="submit" value="Find"/>
</div>
</form>
Thanks in advance for any help. Mike