Button click doesn't work on touch devices


#1

Hey all, noob here. I’m writing my own little beginner web app, but I’ve ran into a problem.
Everything works fine on both desktop and mobile browser when used this approach:


Template.mybutton.events({
  'click': function(){ 

   	setTimeout( function(){    
    Meteor.call( 'raaber', function(err, result) { 
    	if( err ) { console.log("error 500"); return; }
   		else{ 
   			$("#Clickeridoo").text(result); 
   		}
   		});
		}, 300);
    
  }
});

--- server side ---

Meteor.methods({ 

 'raaber': function() {
        var arrayTotal = 0;
        var selectTarget = 0;
        var selectedId = "";
        var arrayObject = [];

        for (var i = 1; i - 1 < Todos.find().count(); i++){
            var firstW = Todos.findOne({'objectId': i}).first.length;
            if (firstW == 0) firstW = 1;
            var secondW = Todos.findOne({'objectId': i}).second.length;
            if (secondW == 0) secondW = 1;
            var thirdW = Todos.findOne({'objectId': i}).third.length;
            if (thirdW == 0) thirdW = 1;
            var fourthW = Todos.findOne({'objectId': i}).fourth.length;
            if (fourthW == 0) fourthW = 1;
            var fifthW = Todos.findOne({'objectId': i}).fifth.length;
            if (fifthW == 0) fifthW = 1;
            var sum = firstW*secondW*thirdW*fourthW*fifthW;
            arrayObject[i] = sum;
            arrayTotal = arrayTotal + sum;

        }


        var arraySelect = Random.fraction() * arrayTotal; // punkt i array som bruges til udvælgelse


        // this gives every combination an even chance of being selected
        for (var i = 1; i - 1 < Todos.find().count(); i++){ 
            selectTarget = selectTarget + arrayObject[i];
            if(arraySelect < selectTarget){
                selectedId = Todos.findOne({'objectId': i})._id;
                break;
            }
        }

        var first = Random.choice(Todos.findOne(selectedId).first);
        var second = Random.choice(Todos.findOne(selectedId).second);
        var third = Random.choice(Todos.findOne(selectedId).third);
        var fourth = Random.choice(Todos.findOne(selectedId).fourth);
        var fifth = Random.choice(Todos.findOne(selectedId).fifth);
        var theCompliment = first + second + third + fourth + fifth;

        return theCompliment;

    }

  });

But I thought that it would be better to keep this on the client-side, so I basically copied the method into the event. But then something strange happen - Everything works perfect on desktop browser, but the button does nothing on touch devices.

I’ve tried’ touchend, click’ but with no success. And I haven’t been able to find an answer using Google, so I hope you guys can point me in the right direction.

Thanks in advance. :slight_smile: