javascript - How can i get form input values by id in meteor -


i new in meteor framework. practice in local server. have added data meteor want edit data. have tried edit data unable values. below code.

<head>   <title>login page</title> </head>  <body>   {{> facebooktest}}   {{> usersdetails}} </body>  <template name="usersdetails">   <table class="userdetailstable">     <tr>       <th>#id</th>       <th>email address</th>       <th>name</th>       <th>username</th>       <th>password</th>       <th>created</th>       <th>edit</th>       <th>delete</th>     </tr>     {{#each returnregistrationdata}}       <tr>         <td>{{_id}}</td>         <td>{{email}}</td>         <td>{{name}}</td>         <td>{{username}}</td>         <td>{{created}}</td>         <td>{{password}}</td>         <td><button class="delete-entry btn btn-primary" id="edit-entry">edit</button></td>         <td><button class="delete-entry btn btn-danger" id="delete-entry">delete</button></td>       </tr>     {{/each}}    </table>  </template>   <template name="facebooktest">    <div class="container">     <button class="login-button">login here</button>     <button class="registration"> registration </button>   </div>     <div class="modal fade" id="login-page">     <div class="modal-dialog modal-sm">       <div class="modal-content">          <div class="modal-header">           <h4 class="modal-title">login</h4>         </div>         <form class="login-form" id="login-form">           <div class="modal-body">               <label for="name">username</label>               <input type="text" id="username" class="username" placeholder="username" value="" />               <label for="name">password</label>               <input type="password" id="password" class="password" placeholder="password" value="" />           </div>           <div class="modal-footer">             <button type="submit" class="btn btn-primary" id="save">submit</button>             <button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>           </div>         </form>        </div>     </div>   </div>     <div class="modal fade" id="registration-page">     <div class="modal-dialog modal-sm">       <div class="modal-content">          <div class="modal-header">           <h4 class="modal-title">registration</h4>         </div>         <form class="login-form" id="login-form">           <div class="modal-body">               <label for="name">email</label>               <input type="email" id="email" class="email" placeholder="email@example.com" value="{{email}}" required />               <label for="name">your name</label>               <input type="text" id="name" class="name" placeholder="your name" value="{{name}}" required/>               <label for="name">username</label>               <input type="text" id="username" class="username" placeholder="username" value="{{username}}" required/>               <label for="name">password</label>               <input type="password" id="password" class="password" placeholder="password" value="{{password}}" required/>           </div>           <div class="modal-footer">             <button type="submit" class="btn btn-primary" id="registration-added">add</button>             <button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>           </div>         </form>        </div>     </div>   </div>  </template> 

below js file code

import { template } 'meteor/templating'; import { reactivevar } 'meteor/reactive-var'; import { registration } '../db/database.js'; import './main.html';  template.body.events({   'click .login-button' : function(event)   {     event.preventdefault();     $('#login-page').modal('show');   },   'click .registration' : function(event)   {     event.preventdefault();     $('#registration-page').modal('show');   } });  template.usersdetails.helpers({     returnregistrationdata : function()     {          return registration.find({});     } });  template.usersdetails.events({     'click #delete-entry' : function(event)     {  //console.log(event.target);         registration.remove(this._id);     },     'click #edit-entry' : function(event)     {         $('#registration-page').modal('show');          var editdata = registration.find(this._id);         console.log(editdata.target);     } }); 

i using modal box when click on buttons. want edit button row values.

http://i.imgur.com/cz79yn9.png

template.facebooktest.events({     'submit #login-form'  : function(event)     {         event.preventdefault();         const target = event.target;         var username = target.username.value;         var password = target.password.value;          if(username == '')         {             alert('please enter username.');             return false;         }         else if(password == '')         {             alert('please enter password.');             return false;         }         else          {                var selectmethod =  registration.find({                 "name" : username,                 "password" : password             });              console.log(selectmethod);             $('#login-page').modal('hide');         }     },     'submit #registration-page' : function(event)     {         event.preventdefault();          const target    = event.target;         const email     = event.target.email.value;         const name      = event.target.name.value;         const username  = event.target.username.value;         const password  = event.target.password.value;          registration.insert({             email,             name,             username,             password,             created : new date(),         });         event.target.email.value = '';         event.target.name.value = '';         event.target.username.value = '';         event.target.password.value = '';         $('#registration-page').modal('hide');      } });  // db.registration.insert({ email: "test@sad.com",name: "test@sad.com",username: "test@sad.com",password: "123456", createdat: new date() }); 


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -