File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1010 < a class ="navbar-brand " href ="{{pathFor 'postsList'}} "> Microscope</ a >
1111 </ div >
1212 < div class ="collapse navbar-collapse " id ="navigation ">
13+ < ul class ="nav navbar-nav ">
14+ < li > < a href ="{{pathFor 'postSubmit'}} "> Submit Post</ a > </ li >
15+ </ ul >
1316 < ul class ="nav navbar-nav navbar-right ">
1417 {{> loginButtons}}
1518 </ ul >
Original file line number Diff line number Diff line change 1+ < template name ="postSubmit ">
2+ < form class ="main form page ">
3+ < div class ="form-group ">
4+ < label class ="control-label " for ="url "> URL</ label >
5+ < div class ="controls ">
6+ < input name ="url " id ="url " type ="text " value ="" placeholder ="Your URL " class ="form-control "/>
7+ </ div >
8+ </ div >
9+ < div class ="form-group ">
10+ < label class ="control-label " for ="title "> Title</ label >
11+ < div class ="controls ">
12+ < input name ="title " id ="title " type ="text " value ="" placeholder ="Name your post " class ="form-control "/>
13+ </ div >
14+ </ div >
15+ < input type ="submit " value ="Submit " class ="btn btn-primary "/>
16+ </ form >
17+ </ template >
Original file line number Diff line number Diff line change 1+ Template . postSubmit . events ( {
2+ 'submit form' : function ( e ) {
3+ e . preventDefault ( ) ;
4+
5+ var post = {
6+ url : $ ( e . target ) . find ( '[name=url]' ) . val ( ) ,
7+ title : $ ( e . target ) . find ( '[name=title]' ) . val ( )
8+ } ;
9+
10+ post . _id = Posts . insert ( post ) ;
11+ Router . go ( 'postPage' , post ) ;
12+ }
13+ } ) ;
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ Router.route('/posts/:_id', {
1212 data : function ( ) { return Posts . findOne ( this . params . _id ) ; }
1313} ) ;
1414
15+ Router . route ( '/submit' , { name : 'postSubmit' } ) ;
16+
1517Router . onBeforeAction ( 'dataNotFound' , { only : 'postPage' } ) ;
You can’t perform that action at this time.
0 commit comments