preventing multiple events with .off().on() vs .one
Since jQuery mobile keeps pages in the dom and I have found that my click events were getting attached multiple times. So I started putting .off before each .on so that I would make sure that each was only called once. However I wonder if using .one is better?
For example which is better?
$(document).off('click', '#barcodescanner').on('click', '#barcodescanner', function() {
or
$(document).one('click', '#barcodescanner', function() {
I personally like .one because it looks cleaner.
Any thoughts?