Last active
August 29, 2015 14:01
-
-
Save kingluddite/11859d3e62c10ce336e6 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
/* /client/main.js */ | |
Session.setDefault('showProjectDialog', false); |
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
<template name="ProjectForm"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h4 class="modal-title">Modal title</h4> | |
</div> | |
<div class="modal-body"> | |
<p> | |
<label for="name">Name:</label> | |
<input type="text" name="name" class="input form-control name" value="{{project.name}}"> | |
</p> | |
<label for="client">Client:</label> | |
<input type="text" name="client" class="input form-control client" value="{{project.client}}"> | |
</div> | |
<div class="modal-footer"> | |
<button type="button" class="btn btn-default cancel" data-dismiss="modal">Close</button> | |
<button type="button" class="btn btn-primary save">Save changes</button> | |
</div> | |
</div><!-- /.modal-content --> | |
</div><!-- /.modal-dialog --> | |
</template> |
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
<template name="Projects"> | |
{{#if showProjectDialog}} | |
{{> ProjectForm}} | |
{{/if}} | |
<div class="page-header"> | |
<h1>Projects<small> list</small></h1> | |
</div> | |
<p> | |
<button type="button" class="btn btn-success addProject">Add Project</button> | |
</p> | |
<table class="table table-bordered table-striped table-hover"> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Client</th> | |
<th>Due Date</th> | |
<th>Status</th> | |
</tr> | |
</thead> | |
<tbody> | |
{{#each projectList}} | |
{{> ProjectRow}} | |
{{/each}} | |
</tbody> | |
</table> | |
</template> |
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
Template.Projects.projectList = function() { | |
return Projects.find(); | |
}; | |
Template.Projects.showProjectDialog = function() { | |
return Session.get('showProjectDialog'); | |
}; | |
Template.Projects.events({ | |
'click .addProject':function(evt, tmpl) { | |
return Session.set('showProjectDialog', true) | |
}, | |
'click .cancel':function(evt, tmpl) { | |
return Session.set('showProjectDialog', false); | |
}, | |
'click .close':function(evt, tmpl) { | |
return Session.set('showProjectDialog', false); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
we have our projects.html that shows the dialog form if the setProjectDialog is true
Why is it camelCase? I camelCase session variables so I can easily see them
we initially set the setProjectDialog to false so it hides when our app loads
in projects.js we build the events that show or hide it based on the setProjectDialog true or false
if they click the add project button (we just add this button) the class name on that button .addProject gives us the ability to set the setProjectDialog session to true
when we click the cancel or close (both targeted by their class names (.close and .cancel))