0

Code For LoginRegister.html
1.Main Page
2.All the templates are working fine.I think there is no issue regarding the html file
3.Problem is in the router.js file

         <!--Home Template !-->
         <template name="home">
         {{> login}}
         </template>

         <!--Layout Template !-->
         <template name="layout"> 
             <header>
               {{> topheader }}
             </header>
             {{> yield}}  
         </template>

         <!--TopHeader Template !-->
         <template name="topheader">  
                <h1>Welcome</h1>        
         </template>

         <!--Login Template !-->
         <template name="login">  
           <form class="form-horizontal">
               <button type="submit" class="btn btn-default signin" id="signInBtn ">Sign in</button>         
               <button type="submit" class="btn btn-default signup" id="signUpBtn ">Sign Up</button>        
          </form>
         </template>

         <!--SignUP Template !-->
         <template name="signup">   
                <h1>SIGNUP <small>Page</small></h1>     
         </template>


Router.js This works correctly , When SignUp button is clicked , it flashes sigup template but again reloads home template with login page
                      Router.configure({ layoutTemplate: 'layout'
}); Router.map(function() { this.route('home',{path: '/'}); this.route('signup',{path: '/signup'}); })


loginRegister.js Java Script File containing events for Both Button Click

          if (Meteor.isClient) {     
           Template.login.events({
                'click .signin': function(evt,tmpl){

                        alert("Sign in button is clicked");
                       console.log("Registration Form submitted.");

                 },
                 'click .signup':function(evt,tmpl)
                 {
                    Router.go('signup', {name: '/signup'});

                 }
           });   
       }

Please help I am stuck and I am new to Meteor so unable to figure it out , and search does not generated good result

4

1 回答 1

3

你需要阻止你的按钮提交,所以在你的注册事件处理程序代码中尝试这样的事情:

'click .signup':function(evt,tmpl)
{
  evt.preventDefault(); // add this to prevent the button from submitting
  Router.go('signup', {name: '/signup'});
}
于 2015-01-11T18:50:22.433 回答