javascript - Capture user input without input field -
i want capture user input in webpage without having input field. screen used mobile device can scan barcode , rfid. capturing input using input
field.
<input id="rfidcontainer"/> <div class="footer-btn confirm td-div"> <img src="img/done.png" /> f1 - confirm </div>
however, user shouldn't able see data scans because has no added value see number. i'm wondering how can capture input without input field?
not relevant current code process input looks this:
views.rfidview = backbone.view.extend({ events: { "click .confirm": "doconfirmscan" }, initialize: function() { this.template = _.template(utils.templateloader.get('rfid')); }, render: function(eventname) { $(this.el).html(this.template(this.model.tojson())); this.$("#rfidcontainer").focus(); return this; }, doconfirmscan : function(){ var rfid= this.$("#rfidcontainer").val(); //the magic.. } });
edit: need clearify making input field invisible or type 'hidden' not allow me focus on scanner not dump it's value anywhere. looking solution without input
field. capturing key events on body
.
any appreceated.
just add
js:
views.rfidview = backbone.view.extend({ $('#results').addclass('hide'); events: { "click .confirm": "doconfirmscan" }, initialize: function() { this.template = _.template(utils.templateloader.get('rfid')); }, render: function(eventname) { $(this.el).html(this.template(this.model.tojson())); this.$("#rfidcontainer").focus(); return this; }, doconfirmscan : function(){ var rfid= this.$("#rfidcontainer").val(); //the magic.. } });
html:
<div id="results"> <input id="rfidcontainer"/> </div> <div class="footer-btn confirm td-div"> <img src="img/done.png" /> f1 - confirm </div>
Comments
Post a Comment