javascript - How to submit a value of hidden input in Meteorjs -


in meteor app, submit value of picker number clicking sbmit button bellow

enter image description here

when tried submit enter key (keyboard), not work, knowing set hidden input , trying submit it; think problem come hidden input after hours of search don't know how submit hidden input, please; here code

<template name="range"> <div class="row"> <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9"> <div class="valuesliders">   <div class="verticlenumberselect">   <span class="firstnumber">     <span class="up"> </span>     <span class="numbervalue" tabindex="1">0</span>     <span class="down"></span>   </span>   <span class="secondnumber">     <span class="up"></span>     <span class="numbervalue" tabindex="1">0</span>     <span class="down"></span>   </span>   <span class="thirdnumber">     <span class="up"></span>     <span class="numbervalue" tabindex="1">0</span>     <span class="down"></span>   </span>   <span class="fourthnumber">     <span class="up"></span>     <span class="numbervalue" tabindex="1">0</span>     <span class="down"></span>   </span>   <form>   <input type="hidden" id="verticlenumber" />   <input type="submit" style="visibility: hidden; position: absolute;" />    </form>  </div> </div> </div> </template> 

and js

template.range.events({ 'submit form': function (event) {      event.preventdefault();      if (session.get('times') && session.get('times') > 0) {     var response, responseclass;     var guess = $('#verticlenumber').val();     if (guess >  answer) {         response = "-";         responseclass = 'lower';     }     else if (guess <  answer) {         response = "+";         responseclass = 'higher';     }     else if (guess ==  answer) {         response = "✔";         responseclass = 'win';       }       }     } }); 

i set value of hidden input dynamically , it's value chosen player picker number, means value of verticlenumber; answer random value

thank's lot

the enter key works on form if considered focused - think form having 1 hidden input preventing ever occurring. assuming submit function not being called @ all, i'd break meteor convention , jquery event listener in template's oncreated function:

$(document).keypress(function(e) {     if(e.which == 13) {         console.log('enter pressed');         // code here values , stuff.     } }); 

Comments